Probability density function (PDF), cumulative density function (CDF), quantile function and random generation for the Generalized Gamma (GG) distribution with 3 or 4 parameters: alpha, scale, mu, and psi. The function is reduced to GGamma distribution with 3 parameters by setting mu = 0.

dggamma(q, alpha = 1, scale = 1, mu = 0, psi = 1, log.p = FALSE)

pggamma(
  q,
  alpha = 1,
  scale = 1,
  mu = 0,
  psi = 1,
  lower.tail = TRUE,
  log.p = FALSE
)

qggamma(
  p,
  alpha = 1,
  scale = 1,
  mu = 0,
  psi = 1,
  lower.tail = TRUE,
  log.p = FALSE
)

rggamma(n, alpha = 1, scale = 1, mu = 0, psi = 1)

Arguments

q

numeric vector.

alpha

numerical parameter, strictly positive (default 1). The generalized gamma becomes the gamma distribution for alpha = 1.

scale, psi

the same real positive parameters as is used for the Gamma distribution. These are numerical and strictly positives; default 1. (see ?pgamma).

mu

location parameter (numerical, default 0).

log.p

logical; if TRUE, probabilities/densities p are returned as log(p).

lower.tail

logical; if TRUE (default), probabilities are \(P(X \leq x)\), otherwise, \(P(X > x)\)

p

vector of probabilities.

n

number of observations.

Value

GG PDF values (3-parameters or 4-parameters) for dggamma, GG probability for pggamma, quantiles or GG random generated values for rggamma.

Details

Details about these function can be found in references 1 to 3. You may also see section Note at ?pgamma or ?rgamma. Herein, we are using Stacy' s formula (references 2 to 3) with the parametrization given in reference 4 (equation 6, page 12). As in the case of gamma distribution function, the cumulative distribution function (as given in equation 12, page 13 from reference 4) is expressed in terms of the lower incomplete gamma function (see ?pgamma).

The GG distribution with parameters \(\alpha\), \(\beta\) (scale), \(\psi\), and \(\mu\) has density:

$$f(x | \alpha, \beta, \mu, \psi) = \alpha exp(-((x-\mu)/ \beta)^\alpha) ((x-\mu)/\beta)^(\alpha * \psi - 1)/(\beta Gamma(\psi))$$

References

  1. Handbook on STATISTICAL DISTRIBUTIONS for experimentalists (p. 73) by Christian Walck. Particle Physics Group Fysikum. University of Stockholm (e-mail: walck@physto.se )

  2. Stacy, E. W. A Generalization of the Gamma Distribution. Ann. Math. Stat. 33, 1187–1192 (1962).

  3. Stacy E, Mihram G (1965) Parameter estimation for a generalized gamma distribution. Technometrics 7: 349-358.

  4. Sanchez, R. & Mackenzie, S. A. Information Thermodynamics of Cytosine DNA Methylation. PLoS One 11, e0150427 (2016).

Examples

q <- (1:9)/10
pggamma(q, alpha = 1, scale = 1, mu = 0,
        psi = 1, lower.tail = TRUE, log.p = FALSE)
#> [1] 0.09516258 0.18126925 0.25918178 0.32967995 0.39346934 0.45118836 0.50341470
#> [8] 0.55067104 0.59343034

## To fit random generated numbers
set.seed(123)
x <- rggamma(2000, alpha = 1.03, psi = 0.75, scale = 2.1)
fitGGammaDist(x)
#> 
#> *** Trying nonlinear fit to a generalized 3P Gamma distribution model 2000 values...
#> *** Performing nonlinear regression model  crossvalidation...
#>        Estimate  Std. Error  t value Pr(>|t|))      Adj.R.Square
#> alpha 0.9673238 0.004522505 213.8911         0 0.999999987853079
#> scale 1.9144847 0.014958737 127.9844         0                  
#> psi   0.8336441 0.005740760 145.2149         0                  
#>                     rho       R.Cross.val                  DEV
#> alpha 0.999999987810436 0.999883383764061 2.02246091084951e-06
#> scale                                                         
#> psi                                                           
#>                     AIC               BIC     COV.alpha     COV.scale
#> alpha -16008.7979704402 -15986.3943606021  2.045305e-05  6.688171e-05
#> scale                                      6.688171e-05  2.237638e-04
#> psi                                       -2.580569e-05 -8.574614e-05
#>             COV.psi COV.mu    N    model
#> alpha -2.580569e-05     NA 2000 GGamma3P
#> scale -8.574614e-05     NA 2000         
#> psi    3.295633e-05     NA 2000