Learn R Programming

VGAM (version 0.7-1)

zipoisson: Zero-Inflated Poisson Distribution Family Function

Description

Fits a zero-inflated Poisson distribution.

Usage

zipoisson(lphi="logit", llambda = "loge", iphi = NULL, zero = NULL)

Arguments

lphi
Link function for the parameter $\phi$. See Links for more choices.
llambda
Link function for the usual $\lambda$ parameter. See Links for more choices.
iphi
Optional initial value for $\phi$, whose value must lie between 0 and 1. The default is to compute an initial value internally.
zero
An integer specifying which linear/additive predictor is modelled as intercepts only. If given, the value must be either 1 or 2, and the default is none of them. Setting zero=1 makes $\phi$ a single parameter.

Value

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

Warning

Numerical problems can occur. Half-stepping is not uncommon. If failure to converge occurs, try using iphi and/or zero=1 if there are explanatory variables.

Details

This function uses Fisher scoring and is based on $$P(Y=0) = \phi + (1-\phi) \exp(-\lambda),$$ and for $y=1,2,\ldots$, $$P(Y=y) = (1-\phi) \exp(-\lambda) \lambda^y / y!.$$ The parameter $\phi$ satisfies $0 < \phi < 1$. The mean of $Y$ is $(1-\phi) \lambda$ and these are returned as the fitted values. By default, the two linear/additive predictors are $(logit(\phi), \log(\lambda))^T$.

References

Thas, O. and Rayner, J. C. W. (2005) Smooth tests for the zero-inflated Poisson distribution. Biometrics, 61, 808--815.

Data: Angers, J-F. and Biswas, A. (2003) A Bayesian analysis of zero-inflated generalized Poisson model. Computational Statistics & Data Analysis, 42, 37--46.

See Also

zapoisson, Zipois, yip88, rpois.

Examples

Run this code
n = 5000
x = runif(n)
phi = logit(-0.5 + 1*x, inverse=TRUE)
lambda = loge(0.5 + 2*x, inverse=TRUE)
y = rzipois(n, lambda, phi)
table(y)
fit = vglm(y ~ x, zipoisson, trace=TRUE)
coef(fit, matrix=TRUE)  # These should agree with the above values


# Another example: data from McKendrick (1926).
y = 0:4  # Number of cholera cases per household in an Indian village
w = c(168, 32, 16, 6, 1)  # Frequencies; there are 223=sum(w) households
fit = vglm(y ~ 1, zipoisson(iphi=0.3), wei=w, trace=TRUE)
coef(fit, matrix=TRUE)
cbind(actual=w, fitted=
      dzipois(y, lambda=Coef(fit)[2], phi=Coef(fit)[1]) * sum(w))


# Another example: data from Angers and Biswas (2003)
y = 0:7
w = c(182, 41, 12, 2, 2, 0, 0, 1)
y = y[w>0]
w = w[w>0]
fit = vglm(y ~ 1, zipoisson(lphi=probit, iphi=0.3), wei=w, tra=TRUE)
fit@misc$prob0  # Estimate of P(Y=0)
coef(fit, matrix=TRUE)
Coef(fit)  # Estimate of phi and lambda
fitted(fit)
weighted.mean(y,w) # Compare this with fitted(fit)
summary(fit)

Run the code above in your browser using DataLab