zic.reg {bizicount}R Documentation

Univariate zero-inflated Poisson and negative binomial regression models


This function from the bizicount package estimates univariate zero-inflated Poisson and negative binomial regression models via maximum likelihood using either the nlm or optim optimization functions. It's class has associated simulate methods for post-estimation diagnostics using the DHARMa package, as well as an extract method for printing professional tables using texreg. Visit the 'See Also' section for links to these methods for zicreg objects.


  fmla = NULL,
  dist = "pois",
  link.ct = "log",
  link.zi = "logit",
  optimizer = "nlm",
  starts = NULL,
  weights = rep(1, length(y)),
  X = NULL,
  z = NULL,
  y = NULL,
  offset.ct = NULL,
  offset.zi = NULL,
  warn.parent = T,
  keep = F,



A formula of the form ⁠y ~ x_1 + x_2 + ... + x_n + offset(count_var) | z_1 + ... z_n + offset(zi_var)⁠, where the x values are covariates in the count portion of the model, and z are in the zero-inflation portion. The z and x variables can be the same. If NULL, design matrices, the response vector, and offsets can be entered directly; see X, z, y, offset.ct, and offset.zi below.


A data.frame containing all variables appearing in fmla, including offsets. If not specified, variables are searched for in parent environment.


The distribution used for the count portion of the zero-inflated mixture. One of c("pois", "nbinom"), partial matching supported.


String specifying the link function used for the count portion of the mixture distribution. One of c("log", "identity", "sqrt"). See family.


Character string specifying the link function used for the zero-inflation portion of the mixture distribution. One of c("logit", "probit", "cauchit", "log", "cloglog"). See family.


String specifying the optimizer to be used for fitting, one of c("nlm", "optim"). If "optim", defaults to method="BFGS".


Optional vector of starting values used for the numerical optimization procedure. Should have count parameters first (with intercept first, if applicable), followed by zero-inflated parameters (with intercept first, if applicable), and the inverse dispersion parameter last (if applicable).


Vector indicating the subset of observations on which to estimate the model


A function which indicates what should happen when the data contain NAs. Default is na.omit.


An optional numeric vector of weights for each observation.

X, z

If fmla = NULL, these are the design matrices of covariates for the count and zero-inflation portions, respectively. Both require no missingness. Similar in spirit to glm.fit in that it can be faster for larger datasets because it bypasses model matrix creation.


If fmla = NULL, a vector containing the response variable.

offset.ct, offset.zi

If fmla = NULL, vectors containing the (constant) offset for the count and zero-inflated portions, respectively. Must be equal in length to y, and row-dim of X, z. If left NULL, defaults to rep(0, length(y)).


Logical indicating whether to warn about data not being supplied.


Logical indicating whether to keep the model matrices in the returned model object. Must be TRUE to use DHARMa and texreg with the model object, e.g., via simulate.zicreg and extract.zicreg, as well as base generics like fitted and predict.


Additional arguments to pass on to the chosen optimizer, either nlm or optim. See 'Examples'.


An S3 zicreg-class object, which is a list containing:


John Niehaus


Lambert, Diane. "Zero-inflated Poisson regression, with an application to defects in manufacturing." Technometrics 34.1 (1992): 1-14.

See Also

simulate.zicreg, extract.zicreg


## ZIP example
# Simulate some zip data
x = cbind(1, rnorm(n))
z = cbind(1, rbeta(n, 4, 8))
b = c(1, 2.2)
g = c(-1, 1.7)
lam = exp(x %*% b)
psi = plogis(z %*% g)

y = bizicount::rzip(n, lambda = lam, psi=psi)
dat = cbind.data.frame(x = x[,-1], z = z[,-1], y = y)

# estimate zip model using NLM, no data.frame

mod = zic.reg(y ~ x[,-1] | z[,-1])

# same model, with dataframe

mod = zic.reg(y ~ x | z, data = dat)

# estimate zip using NLM, adjust stepmax via ... param

mod = zic.reg(y ~ x[,-1] | z[,-1], stepmax = .5)

# estimate zip using optim

mod = zic.reg(y ~ x[,-1] | z[,-1], optimizer = "optim")

# pass different method, reltol to optim using ... param

mod = zic.reg(y ~ x[,-1] | z[,-1],
        optimizer = "optim",
        method = "Nelder-Mead",
        control = list(reltol = 1e-10)

# No formula, specify design matrices and offsets.
zic.reg(y=y, X=x, z=z)

## ZINB example
# simulate zinb data

disp = .5
y = bizicount::rzinb(n, psi = psi, size = disp, mu=lam)

# zinb model, use keep = TRUE for post-estimation methods

mod = zic.reg(y ~ x[,-1] | z[,-1], dist = "n", keep = TRUE)


[Package bizicount version 1.2.0 Index]