I have the parameters of a gamma distribution that I am trying to plot. The parameters are shape = 2, scale = 5.390275 and the minimum value x0 is 65.44945. Since the gamma is shifted by x0, we have Mean = shape*scale + x0 = 76.23 My question is, how can I do it in r? I was trying to use dgamma function, but I saw no options to offset the gamma distribution. I can only use the shape and scale parameters, like this:> x <- seq(from=0, to=100, length.out=100)> plot(x, dgamma(x, shape=2, scale=5.390275),main="Gamma",type='l') This generates a distribution with origin equal zero, but I want the origin to be x0 How can I handle shifted gamma distribution in r? Thanks a lot! Rodrigo. [[alternative HTML version deleted]]
On 13-Feb-2014 15:30:43 Rodrigo Cesar Silva wrote:> I have the parameters of a gamma distribution that I am trying to plot. > The parameters are shape = 2, scale = 5.390275 and the minimum value > x0 is 65.44945. > > Since the gamma is shifted by x0, we have >Mean = shape*scale + x0 = 76.23> > My question is, how can I do it in r? > > I was trying to use dgamma function, but I saw no options to offset > the gamma distribution. I can only use the shape and scale parameters, > like this: > >> x <- seq(from=0, to=100, length.out=100) > >> plot(x, dgamma(x, shape=2, scale=5.390275), > main="Gamma",type='l')If all that is happening is that the distribution is the same as that of a Gamma distribution with origin at 0, but simply shifted to the right by an amount x0 (though I am wondering what context this could arise in), then the commands x <- seq(from=0, to=100, length.out=100) x0 <- 65.44945 plot(x+x0, dgamma(x, shape=2, scale=5.390275), main="Gamma",type='l') will produce such a plot. However, I wonder if you have correctly expressed the problem! Ted.> This generates a distribution with origin equal zero, but I want the > origin to be x0 > > How can I handle shifted gamma distribution in r? > > Thanks a lot! > Rodrigo.------------------------------------------------- E-Mail: (Ted Harding) <Ted.Harding at wlandres.net> Date: 13-Feb-2014 Time: 17:27:29 This message was sent by XFMail
It is not hard to write your own function: dsgamma <- function(x, x0=0, ...) { dgamma(x-x0,...) } and similar for the other functions. You might also want to look at ?curve for plotting (your plotting is fine, curve is just another option). On Thu, Feb 13, 2014 at 8:30 AM, Rodrigo Cesar Silva <rodrigocesar.jo at gmail.com> wrote:> I have the parameters of a gamma distribution that I am trying to plot. The > parameters are shape = 2, scale = 5.390275 and the minimum value x0 is > 65.44945. > > > > Since the gamma is shifted by x0, we have > > > > Mean = shape*scale + x0 = 76.23 > > > > > > > > My question is, how can I do it in r? > > > > I was trying to use dgamma function, but I saw no options to offset the > gamma distribution. I can only use the shape and scale parameters, like > this: > > > >> x <- seq(from=0, to=100, length.out=100) > > > >> plot(x, dgamma(x, shape=2, scale=5.390275), > > main="Gamma",type='l') > > > > This generates a distribution with origin equal zero, but I want the origin > to be x0 > > > > > > How can I handle shifted gamma distribution in r? > > > > Thanks a lot! > > > > > > Rodrigo. > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.-- Gregory (Greg) L. Snow Ph.D. 538280 at gmail.com