dggamma {HelpersMG}R Documentation

Generalized gamma distribution.

Description

Generalized gamma distribution

Usage

dggamma(x, theta, kappa, delta, log = FALSE)

pggamma(q, theta, kappa, delta, lower.tail = TRUE, log.p = FALSE)

qggamma(p, theta, kappa, delta, lower.tail = TRUE, log.p = FALSE)

rggamma(n, theta, kappa, delta)

Arguments

x, q

vector of quantiles.

theta

scale parameter.

kappa

shape parameter.

delta

shape parameter.

log, log.p

logical; if TRUE, probabilities p are given as log(p).

lower.tail

logical; if TRUE (default), probabilities are P[X <= x] otherwise, P[X > x].

p

vector of probabilities.

n

number of observations.

Details

pggamma, qggamma, dggamma, and rggamma are used to model the generalized gamma distribution.

The code is modified from https://rpubs.com/FJRubio/GG.

Value

dggamma gives the density, pggamma gives the distribution function, qggamma gives the quantile function, and rggamma generates random deviates.

Functions

More details here

The generalized gamma is described here https://en.wikipedia.org/wiki/Generalized_gamma_distribution.
With a being theta, b being kappa, and p being delta.
theta, kappa and delta must be all > 0.

Author(s)

Marc Girondot marc.girondot@gmail.com

See Also

Other Distributions: cutter(), dSnbinom(), dbeta_new(), dcutter(), logLik.cutter(), plot.cutter(), print.cutter(), r2norm(), rcutter(), rmnorm(), rnbinom_new()

Examples

# To reproduce the wikipedia page graphic
x <- seq(from=0, to=8, by=0.1)
plot(x, dggamma(x, theta=2, kappa=0.5, delta=0.5), lty=1, col="blue", 
     type="l", lwd=2, xlab="x", ylab="PDF")
lines(x, dggamma(x, theta=1, kappa=1, delta=0.5), lty=1, col="green", lwd=2)
lines(x, dggamma(x, theta=2, kappa=1, delta=2), lty=1, col="red", lwd=2)
lines(x, dggamma(x, theta=5, kappa=1, delta=5), lty=1, col="yellow", lwd=2)
lines(x, dggamma(x, theta=7, kappa=1, delta=7), lty=1, col="grey", lwd=2)
legend("topright", legend=c("a=2, d=0.5, p=0.5", "a=1, d=1, p=0.5", 
                            "a=2, d=1, p=2", "a=5, d=1, p=5", "a=7, d=1, p=7"), 
                            col=c("blue", "green", "red", "yellow", "grey"), 
                            lty=1, lwd=2, bty="n")
par <- c(theta=2, kappa=0.5, delta=0.5)
# Mean, var and sd
mean.ggamma <- function(theta, kappa, delta) 
       return(theta*(gamma((kappa+1)/delta))/gamma(kappa/delta))
var.ggamma <- function(theta, kappa, delta) 
       return(theta^2* ( ( (gamma((kappa+2)/delta))/gamma(kappa/delta) ) - 
                ( (gamma((kappa+1)/delta))/gamma(kappa/delta) )^2 ) )
sd.ggamma <- function(theta, kappa, delta) 
       return(sqrt(theta^2* ( ( (gamma((kappa+2)/delta))/gamma(kappa/delta) ) - 
                ( (gamma((kappa+1)/delta))/gamma(kappa/delta) )^2 ) ))

[Package HelpersMG version 6.1 Index]