Learn R Programming

VGAM (version 0.8-2)

zanegbinomial: Zero-Altered Negative Binomial Distribution

Description

Fits a zero-altered negative binomial distribution based on a conditional model involving a binomial distribution and a positive-negative binomial distribution.

Usage

zanegbinomial(lp0 = "logit", lmunb = "loge", lk = "loge",
              ep0 = list(), emunb =list(), ek = list(), ipnb0 = NULL,
              ik = NULL, zero = -3, cutoff = 0.995, method.init = 1,
              shrinkage.init = 0.95)

Arguments

lp0
Link function for the parameter $p_0$, called p0 here. See Links for more choices.
lmunb
Link function applied to the munb parameter, which is the mean $\mu_{nb}$ of an ordinary negative binomial distribution. See Links for more choices.
lk
Parameter link function applied to the reciprocal of the dispersion parameter, called k. That is, as k increases, the variance of the response decreases. See Links for mo
ep0, emunb, ek
List. Extra argument for the respective links. See earg in Links for general information.
ipnb0
Optional initial values for the probability $p_0$. If given, they must be in $(0,1)$, and it is ok to give one value each for each response/species.
ik
Optional initial values for k. If given, they must be positive, and give one value for each response/species.
zero
Integer valued vector, usually assigned $-3$ or $3$ if used at all. Specifies which of the three linear predictors are modelled as an intercept only. By default, the k parameter (after lk is applied) for each response
cutoff
A numeric which is close to 1 but never exactly 1. Used to specify how many terms of the infinite series are actually used. The sum of the probabilites are added until they reach this value or more. It is like specifying p in an
method.init, shrinkage.init

Value

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

    The fitted.values slot of the fitted object, which should be extracted by the generic function fitted, returns the mean $\mu$ which is given by $$\mu = (1-p_0) \mu_{nb} / [1 - (k/(k+\mu_{nb}))^k].$$

Warning

Convergence for this VGAM family function seems to depend quite strongly on providing good initial values.

Inference obtained from summary.vglm and summary.vgam may or may not be correct. In particular, the p-values, standard errors and degrees of freedom may need adjustment. Use simulation on artificial data to check that these are reasonable.

Details

The response $Y$ is zero with probability $p_0$, or $Y$ has a positive-negative binomial distribution with probability $1-p_0$. Thus $0 < p_0 < 1$, which is modelled as a function of the covariates. The zero-altered negative binomial distribution differs from the zero-inflated negative binomial distribution in that the former has zeros coming from one source, whereas the latter has zeros coming from the negative binomial distribution too. The zero-inflated negative binomial distribution is implemented in the VGAM package. Some people call the zero-altered negative binomial a hurdle model.

For one response/species, by default, the three linear/additive predictors are $(logit(p_0), \log(\mu_{nb}), \log(k))^T$. This vector is recycled for multiple species.

References

Welsh, A. H., Cunningham, R. B., Donnelly, C. F. and Lindenmayer, D. B. (1996) Modelling the abundances of rare species: statistical models for counts with extra zeros. Ecological Modelling, 88, 297--308.

See Also

dzanegbin, posnegbinomial, negbinomial, binomialff, rposnegbin, zinegbinomial, zipoisson, dnbinom, CommonVGAMffArguments.

Examples

Run this code
zdata <- data.frame(x = runif(nn <- 2000))
zdata <- transform(zdata, p0 = logit(-1 + 2*x, inverse = TRUE),
                          y1 = rposnegbin(nn, munb = exp(0+2*x), size = exp(1)),
                          y2 = rposnegbin(nn, munb = exp(1+2*x), size = exp(1)))
zdata <- transform(zdata, y1 = ifelse(runif(nn) < p0, 0, y1),
                          y2 = ifelse(runif(nn) < p0, 0, y2))
with(zdata, table(y1))
with(zdata, table(y2))

fit <- vglm(cbind(y1, y2) ~ x, zanegbinomial, zdata, trace = TRUE)
coef(fit, matrix = TRUE)
head(fitted(fit))
head(predict(fit))

Run the code above in your browser using DataLab