Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

gammaR

2-parameter Gamma Regression Family Function


Description

Estimates the 2-parameter gamma distribution by maximum likelihood estimation.

Usage

gammaR(lrate = "loglink", lshape = "loglink", irate = NULL,
       ishape = NULL, lss = TRUE, zero = "shape")

Arguments

lrate, lshape

Link functions applied to the (positive) rate and shape parameters. See Links for more choices.

irate, ishape

Optional initial values for rate and shape. A NULL means a value is computed internally. If a failure to converge occurs, try using these arguments.

zero, lss

Details at CommonVGAMffArguments.

Details

The density function is given by

f(y; rate, shape) = exp(-rate * y) y^(shape-1) rate^(shape) / gamma(shape)

for shape > 0, rate > 0 and y > 0. Here, gamma(shape) is the gamma function, as in gamma. The mean of Y is mu = shape/rate (returned as the fitted values) with variance sigma^2 = mu^2 /shape = shape/rate^2. By default, the two linear/additive predictors are eta1 = log(rate) and eta2 = log(shape).

Value

An object of class "vglmff" (see vglmff-class). The object is used by modelling functions such as vglm and vgam.

Note

The parameters rate and shape match with the arguments rate and shape of rgamma. The order of the arguments agree too. Here, scale = 1/rate is used, so one can use negloglink. Multiple responses are handled.

If rate = 1 use the family function gamma1 to estimate shape.

The reciprocal of a 2-parameter gamma random variate has an inverse gamma distribution. One might write a VGAM family function called invgammaR() to estimate this, but for now, just feed in the reciprocal of the response.

Author(s)

T. W. Yee

References

Most standard texts on statistical distributions describe the 2-parameter gamma distribution, e.g.,

Forbes, C., Evans, M., Hastings, N. and Peacock, B. (2011). Statistical Distributions, Hoboken, NJ, USA: John Wiley and Sons, Fourth edition.

See Also

gamma1 for the 1-parameter gamma distribution, gamma2 for another parameterization of the 2-parameter gamma distribution, bigamma.mckay for a bivariate gamma distribution, expexpff, simulate.vlm, rgamma, negloglink.

Examples

# Essentially a 1-parameter gamma
gdata <- data.frame(y1 = rgamma(n <- 100, shape =  exp(1)))
fit1 <- vglm(y1 ~ 1, gamma1, data = gdata, trace = TRUE)
fit2 <- vglm(y1 ~ 1, gammaR, data = gdata, trace = TRUE, crit = "coef")
coef(fit2, matrix = TRUE)
Coef(fit2)

# Essentially a 2-parameter gamma
gdata <- data.frame(y2 = rgamma(n = 500, rate = exp(1), shape = exp(2)))
fit2 <- vglm(y2 ~ 1, gammaR, data = gdata, trace = TRUE, crit = "coef")
coef(fit2, matrix = TRUE)
Coef(fit2)
summary(fit2)

VGAM

Vector Generalized Linear and Additive Models

v1.1-5
GPL-3
Authors
Thomas Yee [aut, cre], Cleve Moler [ctb] (author of several LINPACK routines)
Initial release
2021-01-13

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.