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)
numeric vector.
numerical parameter, strictly positive (default 1). The generalized gamma becomes the gamma distribution for alpha = 1.
the same real positive parameters as is used for the Gamma distribution. These are numerical and strictly positives; default 1. (see ?pgamma).
location parameter (numerical, default 0).
logical; if TRUE, probabilities/densities p are returned as log(p).
logical; if TRUE (default), probabilities are \(P(X<=x)\), otherwise, \(P(X > x)\)
vector of probabilities.
number of observations.
GG PDF values (3-parameters or 4-parameters) for dggamma, GG probability for pggamma, quantiles or GG random generated values for rggamma.
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))$$
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).
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)
fitCDF(x, distNames = "Generalized 3P Gamma")
#>
#> *** Fitting Generalized 3P Gamma distribution ...
#> .Fitting Done.
#> ** Done ***
#> ggamma CDF model
#> ------
#> Parameters:
#> Estimate Std. Error t value Pr(>|t|)
#> alpha 0.967329845 0.004522289 213.9027 < 2.22e-16 ***
#> scale 1.914501961 0.014958309 127.9892 < 2.22e-16 ***
#> psi 0.833637086 0.005740664 145.2161 < 2.22e-16 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Residual standard error: 1.591186e-05 on 1997 degrees of freedom
#> Number of iterations to termination: 17
#> Reason for termination: Relative error in the sum of squares is at most `ftol'.
#>
#> Goodness of fit:
#> Adj.R.Square rho R.Cross.val AIC
#> gof 1 1 0.9998835 -16008.8