how to use qgamma in R

sam_rox picture sam_rox · Nov 29, 2015 · Viewed 8.7k times · Source

The gamma distribution with a shape parameter k and a scale parameter theta is defined by enter image description here= enter image description here

In R If I want to find the quantile at 0.05 probability for a gamma distribution with Gamma(10,0.5)

I used

> qgamma(0.05,shape=10,scale=0.5)
[1] 2.712703  

but this is not the value I want. The desired value I get when I use,

qgamma(0.05,10,0.5)
[1] 10.85081    

So what is the difference of qgamma(0.05,10,0.5) and qgamma(0.05,shape=10,scale=0.5).
Why do I get two completely different results?

Answer

IRTFM picture IRTFM · Nov 29, 2015

Read the help page: Scales is the fourth parameter of qgamma. The third parameter is rate = 1/shape. If you want to call qgamma with positional matching of parameters then it should be:

> qgamma(0.05, 10, 1/0.5)
[1] 2.712703