[R] Gamma Distribution - is there any problem with "pgamma"?

Ben Bolker bbolker at gmail.com
Wed Mar 11 12:54:14 CET 2015


Amelia Marsh <amelia_marsh08 <at> yahoo.com> writes:

> 
> Dear R forum
> 
> I have following data
> 
> amounts = c(928906.144,156091.0576,433798.3404,993425.7224,
> 1323976.364,649106.9339, 369967.2612,2528872.35,1226093.655,
> 1145446.149,1809624.453,599329.0394,2200955.213,2583318.064,
> 745625.8069,961828.8828,1744841.313,1939390.005,1077873.654,
> 729924.2713,803584.2636,287020.8529,530910.9004,818574.0089,
> 1908133.51,262336.0893,593808.2542,780258.1354)
 
> # Estimating Gamma distribution parameters
> 
> shape_gamma	    	<-    		(mean(amounts)/sd(amounts))^2 
> 
> scale_gamma      <-    		(sd(amounts)^2/mean(amounts))
>

 The default parameterization of the Gamma distribution in R 
uses a rate parameter, not a scale parameter.  You can override this:
 
Fx <-	pgamma(amounts, shape_gamma, scale=scale_gamma)

or

Fx <-	pgamma(amounts, shape_gamma, rate=1/scale_gamma)

One place you can find a description of the parameterizations
in R is 

http://journal.r-project.org/archive/2013-1/lebauer-dietze-bolker.pdf



More information about the R-help mailing list