Returns a GLM family
object for negative-binomial model with variance quadratically related to the mean \(\mu\): variance=\(\mu+\mu^2\)/shape, with known or unknown underlying Gamma shape parameter. The zero-truncated variant can be specified either as Tnegbin(.)
or as negbin(., trunc = 0L)
. See negbin1
for the alternative negative-binomial model with variance “linearly” related to the mean.
negbin2
can be used instead of
[T]negbin
- together - with - method=c(<"ML"|"REML">,"obs")
.
The results should be similar, so please report any difference to the package maintainer. negbin2
is implemented as an LL-family
, so it cannot be used to obtain results equivalent to [T]negbin
- together - with - method=c(<"ML"|"REML">,"exp")
(i.e., expected-Hessian approximation, see method
).
negbin(shape = stop("negbin's 'shape' must be specified"), link = "log", trunc = -1L)
Tnegbin(shape = stop("negbin's 'shape' must be specified"), link = "log")
# (the shape parameter is actually not requested unless this is used in a glm() call)
#
negbin2(shape = stop("negbin2's 'shape' must be specified"), link = "log", trunc = -1L,
LLF_only = TRUE)
# Same comment about shape, but method="llm.fit" will further be needed in a glm() call.
A family object.
Shape parameter of the underlying Gamma distribution, given that the negbin
family can be represented as a Poisson-Gamma mixture, where the conditional Poisson mean is \(\mu\) times a Gamma random variable with mean 1 and shape shape
(as produced by rgamma(., shape=shape,scale=1/shape)
).
log, sqrt or identity link, specified by any of the available ways for GLM links (name, character string, one-element character vector, or object of class link-glm
as returned by make.link
).
Either 0L
for zero-truncated distribution, or -1L
for default untruncated distribution.
Boolean: whether to use some generic methods or methods specific for GLM response families. Mostly for development purpose, hence better ignored.
shape
is the \(k\) parameter of McCullagh and Nelder (1989, p.373) and the theta
parameter of Venables and Ripley (2002, section 7.4). The latent Gamma variable has mean 1 and variance 1/shape, and the negbin with mean \(\mu\) has variance \(\mu+\mu^2\)/shape.
The name NB_shape
should be used to set values of shape in control arguments of the fitting functions (e.g., fitme(.,init=list(NB_shape=1))
).
McCullagh, P. and Nelder, J.A. (1989) Generalized Linear Models, 2nd edition. London: Chapman & Hall.
Venables, W. N. and Ripley, B. D. (2002) Modern Applied Statistics with S-PLUS. Fourth Edition. Springer.
## Fitting negative binomial model with estimated scale parameter:
data("scotlip")
fitme(cases~I(prop.ag/10)+offset(log(expec)),family=negbin(), data=scotlip)
negfit <- fitme(I(1+cases)~I(prop.ag/10)+offset(log(expec)),family=Tnegbin(), data=scotlip)
simulate(negfit,nsim=3)
Run the code above in your browser using DataLab