negbin {aod} | R Documentation |
Negative-Binomial Model for Counts
Description
The function fits a negative-binomial log linear model accounting for overdispersion in counts .
Usage
negbin(formula, random, data, phi.ini = NULL, warnings = FALSE,
na.action = na.omit, fixpar = list(),
hessian = TRUE, control = list(maxit = 2000), ...)
Arguments
formula |
A formula for the fixed effects. The left-hand side of the formula must be the counts |
random |
A right-hand formula for the overdispersion parameter(s) |
data |
A data frame containing the response ( |
phi.ini |
Initial values for the overdispersion parameter(s) |
warnings |
Logical to control printing of warnings occurring during log-likelihood maximization. Default to FALSE (no printing). |
na.action |
A function name. Indicates which action should be taken in the case of missing value(s). |
fixpar |
A list with 2 components (scalars or vectors) of the same size, indicating which parameters are
fixed (i.e., not optimized) in the global parameter vector |
hessian |
A logical. When set to |
control |
A list to control the optimization parameters. See |
... |
Further arguments passed to |
Details
For a given count , the model is:
with following a Gamma distribution
.
If denote the gamma function, then:
The marginal negative-binomial distribution is:
The function uses the parameterization and
,
where
is a design-matrix,
is a vector of fixed effects,
is the linear predictor and
the overdispersion parameter.
The marginal mean and variance are:
The parameters and
are estimated by maximizing the log-likelihood of the marginal model (using the
function
optim()
). Several explanatory variables are allowed in . Only one is allowed in
.
An offset can be specified in the formula
argument to model rates . The offset and the marginal mean
are
and
, respectively.
Value
An object of formal class “glimML”: see glimML-class
for details.
Author(s)
Matthieu Lesnoff matthieu.lesnoff@cirad.fr, Renaud Lancelot renaud.lancelot@cirad.fr
References
Lawless, J.F., 1987. Negative binomial and mixed Poisson regression. The Canadian Journal of Statistics, 15(3): 209-225.
See Also
glimML-class
, glm
and optim
,
glm.nb
in the recommended package MASS,
gnlr
in package gnlm available at https://www.commanster.eu/rcode.html.
Examples
# without offset
data(salmonella)
negbin(y ~ log(dose + 10) + dose, ~ 1, salmonella)
library(MASS) # function glm.nb in MASS
fm.nb <- glm.nb(y ~ log(dose + 10) + dose,
link = log, data = salmonella)
coef(fm.nb)
1 / fm.nb$theta # theta = 1 / phi
c(logLik(fm.nb), AIC(fm.nb))
# with offset
data(dja)
negbin(y ~ group + offset(log(trisk)), ~ group, dja)
# phi fixed to zero in group TREAT
negbin(y ~ group + offset(log(trisk)), ~ group, dja,
fixpar = list(4, 0))
# glim without overdispersion
summary(glm(y ~ group + offset(log(trisk)),
family = poisson, data = dja))
# phi fixed to zero in both groups
negbin(y ~ group + offset(log(trisk)), ~ group, dja,
fixpar = list(c(3, 4), c(0, 0)))