Learn R Programming

VGAM (version 0.8-1)

gamma2: 2-parameter Gamma Distribution

Description

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

Usage

gamma2(lmu = "loge", lshape = "loge", emu = list(), eshape = list(),
       method.init = 1, deviance.arg = FALSE, ishape = NULL, zero = -2)

Arguments

lmu, lshape
Link functions applied to the (positive) mu and shape parameters (called $\mu$ and $\lambda$ respectively). See Links for more choices.
emu, eshape
List. Extra argument for each of the links. See earg in Links for general information.
ishape
Optional initial value for shape. A NULL means a value is computed internally. If a failure to converge occurs, try using this argument. This argument is ignored if used within cqo;
method.init
An integer with value 1 or 2 which specifies the initialization method for the $\mu$ parameter. If failure to converge occurs try another value (and/or specify a value for ishape).
deviance.arg
Logical. If TRUE, the deviance function is attached to the object. Under ordinary circumstances, it should be left alone because it really assumes the shape parameter is at the maximum likelihood estimate. Consequently, one cannot use t
zero
Integer valued vector, usually assigned $-2$ or $2$ if used at all. Specifies which of the two linear/additive predictors are modelled as an intercept only. By default, the shape parameter (after lshape is applied) is modelled as

Value

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

Details

This distribution can model continuous skewed responses. The density function is given by $$f(y;\mu,\lambda) = \frac{\exp(-\lambda y / \mu) \times (\lambda y / \mu)^{\lambda-1} \times \lambda}{ \mu \times \Gamma(\lambda)}$$ for $\mu > 0$, $\lambda > 0$ and $y > 0$. Here, $\Gamma(\cdot)$ is the gamma function, as in gamma. The mean of Y is $\mu=\mu$ (returned as the fitted values) with variance $\sigma^2 = \mu^2 / \lambda$. If $0<\lambda<1$ then="" the="" density="" has="" a="" pole="" at="" origin="" and="" decreases="" monotonically="" as="" $y$="" increases.="" if="" $\lambda="1$" this="" corresponds="" to="" exponential="" distribution.="">1$ then the density is zero at the origin and is unimodal with mode at $y = \mu - \mu / \lambda$; this can be achieved with lshape="loglog".

By default, the two linear/additive predictors are $\eta_1=\log(\mu)$ and $\eta_2=\log(\lambda)$. 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.

References

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.

See Also

gamma1 for the 1-parameter gamma distribution, gamma2.ab for another parameterization of the 2-parameter gamma distribution, bivgamma.mckay for a bivariate gamma distribution, expexp, GammaDist, golf.

Examples

Run this code
# Essentially a 1-parameter gamma
gdata = data.frame(y = rgamma(n=100, shape= exp(1)))
fit1 = vglm(y ~ 1, gamma1, gdata)
fit2 = vglm(y ~ 1, gamma2, gdata, trace=TRUE, crit="c")
coef(fit2, matrix=TRUE)
Coef(fit2)


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

Run the code above in your browser using DataLab