Estimates the 2-parameter gamma distribution by maximum likelihood estimation.
gamma2(lmu = "loglink", lshape = "loglink", imethod = 1, ishape = NULL, parallel = FALSE, deviance.arg = FALSE, zero = "shape")
Link functions applied to the (positive) mu and shape
parameters (called mu and shape respectively).
Optional initial value for shape.
An integer with value
This distribution can model continuous skewed responses. The density function is given by
f(y;mu,shape) = exp(-shape * y / mu) y^(shape-1) shape^(shape) / [mu^(shape) * gamma(shape)]
mu > 0,
shape > 0
and y > 0.
gamma() is the gamma
function, as in
The mean of Y is mu=mu (returned as the fitted
values) with variance sigma^2 =
mu^2 / shape. If 0<shape<1 then the density has a
pole at the origin and decreases monotonically as y increases.
If shape=1 then this corresponds to the exponential
distribution. If shape>1 then the density is zero at the
origin and is unimodal with mode at y =
mu - mu / shape; this can be achieved with
By default, the two linear/additive predictors are eta1=log(mu) and eta2=log(shape). This family function implements Fisher scoring and the working weight matrices are diagonal.
This VGAM family function handles multivariate responses,
so that a matrix can be used as the response. The number of columns is
the number of species, say, and
zero=-2 means that all
species have a shape parameter equalling a (different) intercept only.
An object of class
The object is used by modelling functions such as
The response must be strictly positive. A moment estimator for the shape parameter may be implemented in the future.
shape are vectors, then
rgamma(n = n,
shape = shape, scale = mu/shape) will generate random gamma variates of this
T. W. Yee
The parameterization of this VGAM family function is the 2-parameter gamma distribution described in the monograph
McCullagh, P. and Nelder, J. A. (1989). Generalized Linear Models, 2nd ed. London: Chapman & Hall.
gamma1 for the 1-parameter gamma distribution,
gammaR for another parameterization of
the 2-parameter gamma distribution that is directly matched
bigamma.mckay for a bivariate gamma distribution,
# Essentially a 1-parameter gamma gdata <- data.frame(y = rgamma(n = 100, shape = exp(1))) fit1 <- vglm(y ~ 1, gamma1, data = gdata) fit2 <- vglm(y ~ 1, gamma2, data = gdata, trace = TRUE, crit = "coef") coef(fit2, matrix = TRUE) c(Coef(fit2), colMeans(gdata)) # Essentially a 2-parameter gamma gdata <- data.frame(y = rgamma(n = 500, rate = exp(-1), shape = exp(2))) fit2 <- vglm(y ~ 1, gamma2, data = gdata, trace = TRUE, crit = "coef") coef(fit2, matrix = TRUE) c(Coef(fit2), colMeans(gdata)) summary(fit2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.