Description Usage Arguments Details Value Warning Note Author(s) References See Also Examples

Estimates the 2-parameter Inverse Gamma distribution by maximum likelihood estimation.

1 2 3 4 5 6 | ```
invgamma2mr(lmu = "loglink",
lshape = logofflink(offset = -2),
parallel = FALSE,
ishape = NULL,
imethod = 1,
zero = "shape")
``` |

`lmu, lshape` |
Link functions applied to the (positives) |

`parallel` |
Same as |

`ishape` |
Optional initial value for |

`imethod` |
Same as |

`zero` |
Numeric or character vector. Position or name(s) of the
parameters/linear predictors to be
modeled as interceptâ€“only. Default is |

The Gamma distribution and the Inverse Gamma distribution are related
as follows:Let *X* be a random variable distributed as
*Gamma (a , b)*, where *a > 0*
denotes the *shape* parameter and *b > 0* is the
*scale* paramater. Then *Y = 1/X* is an Inverse Gamma
random variable with parameters *scale* = *a* and
*shape* = *1/b*.

The Inverse Gamma density function is given by

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

for *mu > 0*, *shape > 0* and *y > 0*.
Here, *gamma()* 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 / (shape - 2)*
if *shape > 2*, else is infinite. Thus, the
*link function* for the *shape* parameter is
`logloglink`

. Then, by default, the two
linear/additive predictors are *eta1=log(mu)*,
and *eta2=loglog(shape)*, i.e in the VGLM context,
*eta = (log(mu), loglog(shape)).*

This VGAM family function handles *multiple* reponses by
implementing Fisher scoring and unlike
`gamma2`

, the working-weight matrices
are *not* diagonal.
The Inverse Gamma distribution is right-skewed and either for small values
of *shape* (plus modest *mu*) or very large values of
*mu* (plus moderate *shape > 2*), the density has
values too close to zero.

An object of class `"vglmff"`

(see `vglmff-class`

).
The object is used by modelling functions such as `vglm`

and `vgam`

.

Note that `zero`

can be a **numeric** or a **character**
vector specifying the position of the names
(partially or not) of the linear predictor modeled as intercept only.
In this family function such names are

`c("mu", "shape")`

.

Numeric values can be entered as usual.
See `CommonVGAMffArguments`

for further details.

The response must be strictly positive.

If `mu`

and `shape`

are vectors, then ```
rinvgamma(n = n,
shape = shape, scale = mu/(shape - 1)
```

will generate random inverse gamma
variates of this parameterization, etc.;
see `invgammaDist`

.

Given the math relation between the Gamma and the Inverse Gamma distributions, the parameterization of this VGAM family function underlies on the parametrization of the 2-parameter gamma distribution described in the monograph

Victor Miranda and T. W. Yee

McCullagh, P. and Nelder, J. A. (1989)
*Generalized Linear Models*,
2nd ed. London, UK. Chapman & Hall.

`invgammaDist`

,
`gamma2`

for the 2-parameter gamma distribution,
`GammaDist`

,
`CommonVGAMffArguments`

,

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | ```
#------------------------------------------------------------------------#
# Essentially fitting a 2-parameter inverse gamma distribution
# with 2 responses.
set.seed(101)
y1 = rinvgamma(n = 500, scale = exp(2.0), shape = exp(2.0))
y2 = rinvgamma(n = 500, scale = exp(2.5), shape = exp(2.5))
gdata <- data.frame(y1, y2)
fit1 <- vglm(cbind(y1, y2) ~ 1,
family = invgamma2mr(zero = NULL,
# OPTIONAL INITIAL VALUE
# ishape = exp(2),
imethod = 1),
data = gdata, trace = TRUE)
Coef(fit1)
c(Coef(fit1), log(mean(gdata$y1)), log(mean(gdata$y2)))
summary(fit1)
vcov(fit1, untransform = TRUE)
#------------------------------------------------------------------------#
# An example including one covariate.
# Note that the x2 affects the shape parameter, which implies that both,
# 'mu' and 'shape' are affected.
# Consequently, zero must be set as NULL !
x2 <- runif(1000)
gdata <- data.frame(y3 = rinvgamma(n = 1000,
scale = exp(2.0),
shape = exp(2.0 + x2)))
fit2 <- vglm(y3 ~ x2,
family = invgamma2mr(lshape = "loglink", zero = NULL),
data = gdata, trace = TRUE)
coef(fit2, matrix = TRUE)
summary(fit2)
vcov(fit2)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.