[R] (no subject)

Ben Bolker bolker at ufl.edu
Fri Aug 17 17:30:30 CEST 2007


mara serrano <teachermara <at> yahoo.com> writes:

> 
> hi,
> i'm new to R and i'm trying to port a quattro pro spreadsheet into R.
spreadsheets have optional lower and
> upper limit parameters on the beta distribution function. i would like to know
how to incorporate this
> with R's pbeta function.
> 
> thanks in advance,
> mara.

  I think (?) you may mean a beta distribution with
limits scaled other than the standard 0 and 1.
You will have to construct these yourself but it's
fairly easy to do, e.g.

dbeta.scaled <- function(x,shape1,shape2,min,max,...) {
   x.scaled <- (x-min)/(max-min)
   dbeta(x.scaled,shape1,shape2,...)
}

and similarly for pbeta.

For rbeta (and qbeta) the scaling has to go in the other direction.

rbeta.scaled <- function(n,shape1,shape2,min,max,...) {
  min+(max-min)*rbeta(n,shape1,shape2,...)
}

  I did something like this for Tiwari et al. (2006)
Marine Ecology Progress Series 326:283-293 (although the
paper doesn't include any R code).

  cheers
    Ben Bolker



More information about the R-help mailing list