How can I evaluate the shape and scale of gamma difference. with a certain average and a 95% quantile?

Is there any way in R to calculate the scale and shape of the gamma distribution, given the specific mean (or median) and specific quantile (95% quantile)?

So for example, I have mean = 130

and 95% quantile = 300

with distribution bias at 80

Is there a way to get the scale and shape of the gamut that meet these criteria?

+4
source share
1 answer

Here is one approach:

myfun <- function(shape) { scale <- 130/shape pgamma(300, shape, scale=scale) - 0.95 } tmp <- uniroot( myfun, lower=2, upper=10 ) myshape <- tmp$root myscale <- 130/tmp$root qgamma(0.95, shape=myshape, scale=myscale) integrate( function(x) x*dgamma(x,shape=myshape,scale=myscale), lower=0, upper=Inf ) 

I'm not sure what you mean by an offset of 80, if this is exactly where the gamma becomes nonzero, then subtract 80 from 130 and 300 and do the same as above.

+3
source

All Articles