Fit hurdle regression models for count data via maximum likelihood.
Usage
hurdle(formula, data, subset, na.action, weights, offset,
dist = c("poisson", "negbin", "geometric", "binomial"),
zero.dist = c("binomial", "poisson", "negbin", "geometric"),
link = c("logit", "probit", "cloglog", "cauchit", "log"),
size = NULL, control = hurdle.control(...),
model = TRUE, y = TRUE, x = FALSE, ...)
Arguments
formula
symbolic description of the model, see details.
data, subset, na.action
arguments controlling formula processing via model.frame.
weights
optional numeric vector of weights.
offset
optional numeric vector with an a priori known component to be included in the linear predictor of the count model. See below for more information on offsets.
dist
character specification of count model family.
zero.dist
character specification of the zero hurdle model family.
link
character specification of link function in the binomial zero hurdle (only used if zero.dist = “binomial”.
size
size parameter in case the a binomial count model is used (dist = “binomial”). By default the maximum count is used.
control
a list of control arguments specified via hurdle.control.
model, y, x
logicals. If TRUE the corresponding components of the fit (model frame, response, model matrix) are returned.
…
arguments passed to hurdle.control in the default setup.
Details
Hurdle count models are two-component models with a truncated count component for positive counts and a hurdle component that models the zero counts. Thus, unlike zero-inflation models, there are not two sources of zeros: the count model is only employed if the hurdle for modeling the occurence of zeros is exceeded. The count model is typically a truncated Poisson or negative binomial regression (with log link). The geometric distribution is a special case of the negative binomial with size parameter equal to 1. For modeling the hurdle (occurence of positive counts) either a binomial model can be employed or a censored count distribution. Binomial logit and censored geometric models as the hurdle part both lead to the same likelihood function and thus to the same coefficient estimates. A censored negative binomial model for the zero hurdle is only identified if there is at least one non-constant regressor with (true) coefficient different from zero (and if all coefficients are close to zero the model can be poorly conditioned).
The formula can be used to specify both components of the model: If a formula of type y ~ x1 + x2 is supplied, then the same regressors are employed in both components. This is equivalent to y ~ x1 + x2 | x1 + x2. Of course, a different set of regressors could be specified for the zero hurdle component, e.g., y ~ x1 + x2 | z1 + z2 + z3 giving the count data model y ~ x1 + x2 conditional on (|) the zero hurdle model y ~ z1 + z2 + z3.
Offsets can be specified in both parts of the model pertaining to count and zero hurdle model: y ~ x1 + offset(x2) | z1 + z2 + offset(z3), where x2 is used as an offset (i.e., with coefficient fixed to 1) in the count part and z3 analogously in the zero hurdle part. By the rule stated above y ~ x1 + offset(x2) is expanded to y ~ x1 + offset(x2) | x1 + offset(x2). Instead of using the offset() wrapper within the formula, the offset argument can also be employed which sets an offset only for the count model. Thus, formula = y ~ x1 and offset = x2 is equivalent to formula = y ~ x1 + offset(x2) | x1.
All parameters are estimated by maximum likelihood using optim, with control options set in hurdle.control. Starting values can be supplied, otherwise they are estimated by glm.fit (the default). By default, the two components of the model are estimated separately using two optim calls. Standard errors are derived numerically using the Hessian matrix returned by optim. See hurdle.control for details.
The returned fitted model object is of class “hurdle” and is similar to fitted “glm” objects. For elements such as “coefficients” or “terms” a list is returned with elements for the zero and count components, respectively. For details see below.
A set of standard extractor functions for fitted model objects is available for objects of class “hurdle”, including methods to the generic functions print, summary, coef, vcov, logLik, residuals, predict, fitted, terms, model.matrix. See predict.hurdle for more details on all methods.
Value
An object of class “hurdle”, i.e., a list with components including
coefficients
a list with elements “count” and “zero” containing the coefficients from the respective models,
residuals
a vector of raw residuals (observed - fitted),
fitted.values
a vector of fitted means,
optim
a list (of lists) with the output(s) from the optim call(s) for minimizing the negative log-likelihood(s),
control
the control arguments passed to the optim call,
start
the starting values for the parameters passed to the optim call(s),
weights
the case weights used,
offset
a list with elements “count” and “zero” containing the offset vectors (if any) from the respective models,
n
number of observations (with weights > 0),
df.null
residual degrees of freedom for the null model (= n - 2),
df.residual
residual degrees of freedom for fitted model,
terms
a list with elements “count”, “zero” and “full” containing the terms objects for the respective models,
theta
estimate of the additional \(\theta\) parameter of the negative binomial model(s) (if negative binomial component is used),
SE.logtheta
standard error(s) for \(\log(\theta)\),
loglik
log-likelihood of the fitted model,
vcov
covariance matrix of all coefficients in the model (derived from the Hessian of the optim output(s)),
dist
a list with elements “count” and “zero” with character strings describing the respective distributions used,
link
character string describing the link if a binomial zero hurdle model is used,
linkinv
the inverse link function corresponding to link,
converged
logical indicating successful convergence of optim,
call
the original function call,
formula
the original formula,
levels
levels of the categorical regressors,
contrasts
a list with elements “count” and “zero” containing the contrasts corresponding to levels from the respective models,
model
the full model frame (if model = TRUE),
y
the response count vector (if y = TRUE),
x
a list with elements “count” and “zero” containing the model matrices from the respective models (if x = TRUE).
References
Cameron AC, Trivedi PK (2013). Regression Analysis of Count Data, 2nd ed. New York: Cambridge University Press.
Cameron AC, Trivedi PK (2005). Microeconometrics: Methods and Applications. Cambridge: Cambridge University Press.
Mullahy J (1986). “Specification and Testing of Some Modified Count Data Models”. Journal of Econometrics. 33, 341–365.
Zeileis A, Kleiber C, Jackman S (2008). “Regression Models for Count Data in R.” Journal of Statistical Software, 27(8), 1–25. doi:10.18637/jss.v027.i08.
See Also
hurdle.control, glm, glm.fit, glm.nb, zeroinfl
Examples
library("countreg")## datadata("CrabSatellites", package ="countreg")cs<-CrabSatellites[, c("satellites", "width", "color")]cs$color<-as.numeric(cs$color)## logit-poisson## "satellites ~ ." is the same as "satellites ~ . | .", i.e.## "satellites ~ width + color | width + color"fm_hp1<-hurdle(satellites~., data =cs)summary(fm_hp1)
Call:
hurdle(formula = satellites ~ ., data = cs)
Pearson residuals:
Min 1Q Median 3Q Max
-1.7371 -0.8383 -0.2976 0.6431 4.2699
Count model coefficients (truncated poisson with log link):
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.562699 0.645439 0.872 0.383
width 0.034238 0.022227 1.540 0.123
color 0.007165 0.066627 0.108 0.914
Zero hurdle model coefficients (binomial with logit link):
Estimate Std. Error z value Pr(>|z|)
(Intercept) -10.0708 2.8065 -3.588 0.000333 ***
width 0.4583 0.1040 4.407 1.05e-05 ***
color -0.5090 0.2237 -2.276 0.022862 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Number of iterations in BFGS optimization: 13
Log-likelihood: -362.1 on 6 Df
## geometric-poissonfm_hp2<-hurdle(satellites~., data =cs, zero ="geometric")summary(fm_hp2)
Call:
hurdle(formula = satellites ~ ., data = cs, zero.dist = "geometric")
Pearson residuals:
Min 1Q Median 3Q Max
-1.7371 -0.8383 -0.2976 0.6431 4.2699
Count model coefficients (truncated poisson with log link):
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.562699 0.645439 0.872 0.383
width 0.034238 0.022227 1.540 0.123
color 0.007165 0.066627 0.108 0.914
Zero hurdle model coefficients (censored geometric with log link):
Estimate Std. Error z value Pr(>|z|)
(Intercept) -10.0708 2.8065 -3.588 0.000333 ***
width 0.4583 0.1040 4.407 1.05e-05 ***
color -0.5090 0.2237 -2.276 0.022862 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Number of iterations in BFGS optimization: 13
Log-likelihood: -362.1 on 6 Df
## logit and geometric model are equivalentcoef(fm_hp1, model ="zero")-coef(fm_hp2, model ="zero")
(Intercept) width color
0 0 0
## logit-negbinfm_hnb1<-hurdle(satellites~., data =cs, dist ="negbin")summary(fm_hnb1)
Call:
hurdle(formula = satellites ~ ., data = cs, dist = "negbin")
Pearson residuals:
Min 1Q Median 3Q Max
-1.3835 -0.7244 -0.2636 0.5557 3.6080
Count model coefficients (truncated negbin with log link):
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.428567 0.941077 0.455 0.649
width 0.037845 0.032749 1.156 0.248
color 0.006929 0.091078 0.076 0.939
Log(theta) 1.527382 0.352950 4.327 1.51e-05 ***
Zero hurdle model coefficients (binomial with logit link):
Estimate Std. Error z value Pr(>|z|)
(Intercept) -10.0708 2.8065 -3.588 0.000333 ***
width 0.4583 0.1040 4.407 1.05e-05 ***
color -0.5090 0.2237 -2.276 0.022862 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Theta: count = 4.6061
Number of iterations in BFGS optimization: 17
Log-likelihood: -350.4 on 7 Df
## negbin-negbin## (poorly conditioned zero hurdle, note increased standard errors)fm_hnb2<-hurdle(satellites~., data =cs, dist ="negbin", zero ="negbin")summary(fm_hnb2)
Call:
hurdle(formula = satellites ~ ., data = cs, dist = "negbin", zero.dist = "negbin")
Pearson residuals:
Min 1Q Median 3Q Max
-1.3984 -0.7163 -0.2724 0.5615 3.6221
Count model coefficients (truncated negbin with log link):
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.428567 0.941077 0.455 0.649
width 0.037845 0.032749 1.156 0.248
color 0.006929 0.091078 0.076 0.939
Log(theta) 1.527382 0.352950 4.327 1.51e-05 ***
Zero hurdle model coefficients (censored negbin with log link):
Estimate Std. Error z value Pr(>|z|)
(Intercept) -8.7334 5.6289 -1.552 0.121
width 0.3872 0.2840 1.363 0.173
color -0.4097 0.4230 -0.969 0.333
Log(theta) 0.5124 2.5691 0.199 0.842
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Theta: count = 4.6061, zero = 1.6693
Number of iterations in BFGS optimization: 35
Log-likelihood: -350.3 on 8 Df