R: Fit a Negative Binomial Generalized Linear Model

glm.nb {MASS} | R Documentation

## Fit a Negative Binomial Generalized Linear Model

### Description

A modification of the system function `glm()` to include estimation of the additional parameter, `theta`, for a Negative Binomial generalized linear model.

### Usage

    glm.nb(formula, data, weights, subset, na.action,
           start = NULL, etastart, mustart,
           control = glm.control(...), method = "glm.fit",
           model = TRUE, x = FALSE, y = TRUE, contrasts = NULL, ...,
           init.theta, link = log)

### Arguments

`formula, data, weights, subset, na.action, start, etastart, mustart, control, method, model, x, y, contrasts, ...` | arguments for the `glm()` function. Note that these exclude `family` and `offset` (but `offset()` can be used).
`init.theta` | Optional initial value for the theta parameter. If omitted a moment estimator after an initial fit using a Poisson GLM is used.
`link` | The link function. Currently must be one of `log`, `sqrt` or `identity`.

### Details

An alternating iteration process is used. For given `theta` the GLM is fitted using the same process as used by `glm()`. For fixed means the `theta` parameter is estimated using score and information iterations. The two are alternated until convergence of both. (The number of alternations and the number of iterations when estimating `theta` are controlled by the `maxit` parameter of `glm.control`.)

Setting `trace > 0` traces the alternating iteration process. Setting `trace > 1` traces the `glm` fit, and setting `trace > 2` traces the estimation of `theta`.

### Value

A fitted model object of class `negbin` inheriting from `glm` and `lm`. The object is like the output of `glm` but contains three additional components, namely `theta` for the ML estimate of theta, `SE.theta` for its approximate standard error (using observed rather than expected information), and `twologlik` for twice the log-likelihood function.

### References

Venables, W. N. and Ripley, B. D. (2002) Modern Applied Statistics with S. Fourth edition. Springer.

### See Also

`glm`, `negative.binomial`, `anova.negbin`, `summary.negbin`, `theta.md`

There is a `simulate` method.

### Examples

    quine.nb1 <- glm.nb(Days ~ Sex/(Age + Eth*Lrn), data = quine)
    quine.nb2 <- update(quine.nb1, . ~ . + Sex:Age:Lrn)
    quine.nb3 <- update(quine.nb2, Days ~ .^4)
    anova(quine.nb1, quine.nb2, quine.nb3)

[Package MASS version 7.3-18 Index]