# Zero-inflated Count Data Regression:
# Fit zero-inflated regression models for count data via maximum likelihood.
library(pscl)
## data
(data("bioChemists", package = "pscl"))
## without inflation
## ("art ~ ." is "art ~ fem + mar + kid5 + phd + ment")
(fm_pois <- glm(art ~ ., data = bioChemists, family = poisson))
(fm_qpois <- glm(art ~ ., data = bioChemists, family = quasipoisson))
(fm_nb <- MASS::glm.nb(art ~ ., data = bioChemists))
## with simple inflation (no regressors for zero component))
(fm_zip <- zeroinfl(art ~ . | 1, data = bioChemists))
(fm_zinb <- zeroinfl(art ~ . | 1, data = bioChemists, dist = "negbin"))
(
## inflation with regressors
## ("art ~ . | ." is "art ~ fem + mar + kid5 + phd + ment | fem + mar + kid5 + phd + ment")
(fm_zip2 <- zeroinfl(art ~ . | ., data = bioChemists))
(fm_zinb2 <- zeroinfl(art ~ . | ., data = bioChemists, dist = "negbin"))