zerotrunc | R Documentation |
Fit zero-truncated regression models for count data via maximum likelihood.
zerotrunc(formula, data, subset, na.action, weights, offset,
dist = c("poisson", "negbin", "geometric"), theta = Inf,
control = zerotrunc.control(...),
model = TRUE, y = TRUE, x = FALSE, ...)
formula |
symbolic description of the model. |
data, subset, na.action |
arguments controlling formula processing
via |
weights |
optional numeric vector of weights. |
offset |
optional numeric vector with an a priori known component to be included in the linear predictor. |
dist |
character specification of the count distribution family. |
theta |
numeric. Alternative (and more flexible) specification of the
count distribution family. Some values correspond to |
control |
a list of control arguments specified via
|
model, y, x |
logicals. If |
... |
arguments passed to |
All zero-truncated count data models in zerotrunc
are obtained
from the corresponding untruncated distribution using a log-link
between the mean of the untruncated distribution and the linear predictor.
All parameters are estimated by maximum likelihood using optim
,
with control options set in zerotrunc.control
.
Starting values can be supplied, otherwise they are estimated by glm.fit
(the default). Standard errors are derived numerically using
the Hessian matrix returned by optim
. See
zerotrunc.control
for details.
The returned fitted model object is of class "zerotrunc"
and is similar
to fitted "glm"
objects.
A set of standard extractor functions for fitted model objects is available for
objects of class "zerotrunc"
, including methods to the generic functions
print
, summary
, coef
,
vcov
, logLik
, residuals
,
predict
, fitted
, terms
,
model.frame
, model.matrix
. See
predict.zerotrunc
for more details on all methods.
An object of class "zerotrunc"
, i.e., a list with components including
coefficients |
estimated coefficients, |
residuals |
a vector of raw residuals (observed - fitted), |
fitted.values |
a vector of fitted means, |
optim |
a list with the output from the |
control |
the control arguments passed to the |
start |
the starting values for the parameters passed to the |
weights |
the case weights used (if any), |
offset |
the offset vector used (if any), |
n |
number of observations, |
df.null |
residual degrees of freedom for the null model, |
df.residual |
residual degrees of freedom for fitted model, |
terms |
terms objects for the model, |
theta |
(estimated) |
SE.logtheta |
standard error for |
loglik |
log-likelihood of the fitted model, |
vcov |
covariance matrix of the coefficients in the model (derived from the
Hessian of the |
dist |
character describing the distribution used, |
converged |
logical indicating successful convergence of |
call |
the original function call, |
formula |
the original formula, |
levels |
levels of the categorical regressors, |
contrasts |
contrasts corresponding to |
model |
the model frame (if |
y |
the response count vector (if |
x |
model matrix (if |
Cameron AC, Trivedi PK (2013). Regression Analysis of Count Data, 2nd ed. New York: Cambridge University Press.
Zeileis A, Kleiber C, Jackman S (2008). “Regression Models for Count Data in R.” Journal of Statistical Software, 27(8), 1–25. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.18637/jss.v027.i08")}.
zerotrunc.control
, glm
,
glm.fit
, glm.nb
,
zeroinfl
, hurdle
## data
data("CrabSatellites", package = "countreg")
cs <- CrabSatellites[, c("satellites", "width", "color")]
cs$color <- as.numeric(cs$color)
cs <- subset(cs, subset = satellites > 0)
## poisson
zt_p <- zerotrunc(satellites ~ ., data = cs)
## or equivalently
zt_p <- zerotrunc(satellites ~ ., data = cs, theta = Inf)
summary(zt_p)
## negbin
zt_nb <- zerotrunc(satellites ~ ., data = cs, dist = "negbin")
## or equivalently
zt_nb <- zerotrunc(satellites ~ ., data = cs, theta = NULL)
summary(zt_nb)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.