| zic.reg | R Documentation |
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.
zic.reg(
fmla = NULL,
data,
dist = "pois",
link.ct = "log",
link.zi = "logit",
optimizer = "nlm",
starts = NULL,
subset,
na.action,
weights = rep(1, length(y)),
X = NULL,
z = NULL,
y = NULL,
offset.ct = NULL,
offset.zi = NULL,
warn.parent = T,
keep = F,
...
)
fmla |
A |
data |
A |
dist |
The distribution used for the count portion of the zero-inflated
mixture. One of |
link.ct |
String specifying the link function used for the count portion
of the mixture distribution. One of |
link.zi |
Character string specifying the link function used for the
zero-inflation portion of the mixture distribution. One of |
optimizer |
String specifying the optimizer to be used for fitting, one
of |
starts |
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). |
subset |
Vector indicating the subset of observations on which to estimate the model |
na.action |
A function which indicates what should happen when the data
contain NAs. Default is |
weights |
An optional numeric vector of weights for each observation. |
X, z |
If |
y |
If |
offset.ct, offset.zi |
If |
warn.parent |
Logical indicating whether to warn about |
keep |
Logical indicating whether to keep the model matrices in the
returned model object. Must be |
... |
Additional arguments to pass on to the chosen optimizer, either
|
An S3 zicreg-class object, which is a list containing:
call – The original function call
obj – The class of the object
coef – Vector of coefficients, with count, then zi, then dispersion.
se – Vector of asymptotic standard errors
grad – Gradient vector at convergence
link.ct – Name of link used for count portion
link.zi – Name of link used for zero-inflated portion
dist – Name of distribution used for count portion
optimizer – Name of optimization package used in fitting
coefmat.ct – Coefficient matrix for count portion
coefmat.zi – Coefficient matrix for zero-inflated portion
convergence – Convergence code from optimization routine.
coefmat.all – Coefficient matrix for both parts of the model
theta – Coefficient matrix for dispersion, if applicable.
covmat – Asymptotic covariance matrix
nobs – Number of observations
aic – Akaike information
bic – Bayes information
loglik – Log-likelihood at convergence
model – List containing model matrices if keep = TRUE
John Niehaus
Lambert, Diane. "Zero-inflated Poisson regression, with an application to defects in manufacturing." Technometrics 34.1 (1992): 1-14.
simulate.zicreg, extract.zicreg
## ZIP example
# Simulate some zip data
n=1000
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)
print(mod)
summary(mod)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.