htobit.Rd
Fitting tobit regression models with conditional heteroscedasticity.
htobit(formula, data, subset, na.action, model = TRUE, y = TRUE, x = FALSE, control = htobit_control(…), …) htobit_fit(x, y, z = NULL, control) htobit_control(maxit = 5000, start = NULL, grad = TRUE, hessian = TRUE, ...)
formula | a formula expression of the form |
---|---|
data | an optional data frame containing the variables occurring in the formulas. |
subset | an optional vector specifying a subset of observations to be used for fitting. |
na.action | a function which indicates what should happen when the data
contain |
model | logical. If |
x, y | for |
z | a design matrix with regressors for the scale. |
… | arguments to be used to form the default |
control, maxit, start | a list of control parameters passed to |
grad | logical. Should gradients be used for optimization? If |
hessian | logical or character. Should a numeric approximation of the
(negative) Hessian matrix be computed? Either |
htobit
fits tobit regression models with conditional heteroscedasticity
using maximum likelihood estimation. The model assumes an underlying latent
Gaussian variable
$$y_i^* \sim \mathcal{N}(\mu_i, \sigma_i^2)$$
which is only observed if positive and zero otherwise: \(y_i = \max(0, y_i^*)\). The latent mean \(\mu_i\) and scale \(\sigma_i\) (latent standard deviation) are linked to two different linear predictors
$$\mu_i = x_i^\top \beta$$
$$\log(\sigma_i) = z_i^\top \gamma$$
where the regressor vectors \(x_i\) and \(z_i\) can be set up without restrictions, i.e., they can be identical, overlapping or completely different or just including an intercept, etc.
htobit_fit
is the lower level function where the actual fitting takes place.
A set of standard extractor functions for fitted model objects is available for
objects of class "htobit"
, including methods to the generic functions
print
, summary
, coef
,
vcov
, logLik
, residuals
,
predict
, terms
,
model.frame
, model.matrix
, update
,
estfun
and bread
(from the sandwich package),
Boot
(from the car package), and
getSummary
(from the memisc package, enabling mtable
).
See predict.htobit
and coef.htobit
for more details
on some methods with non-standard arguments.
This is a somewhat simpler reimplementation of crch
(Messner, Mayr, Zeileis 2016), illustrating how to create a package from
scratch. Compared to crch
, htobit
does not offer:
other response distributions beyond Gaussian, truncated rather than censored responses,
analytical Hessian, flexible link functions for the scale submodel, boosting rather than
full maximum likelihood estimation, among further features.
htobit
returns an object of class "htobit"
, i.e., a list with components as follows.
htobit_fit
returns an unclassed list with components up to df
.
a list with elements "location"
and "scale"
containing the coefficients from the respective models,
count of function and gradient evaluations from optim
,
convergence code from optim
,
optional further information from optim
,
covariance matrix of all parameters in the model,
a vector of raw residuals (observed - fitted),
a list with elements "location"
and "scale"
containing the latent fitted means and standard deviations,
the method argument passed to the optim
call,
number of observations,
number of estimated parameters,
the original function call,
the original formula,
a list with elements "location"
, "scale"
and
"full"
containing the terms objects for the respective models,
a list with elements "location"
, "scale"
and
"full"
containing the levels of the categorical regressors,
a list with elements "location"
and "scale"
containing the contrasts corresponding to levels
from the
respective models,
the full model frame (if model = TRUE
),
the numeric response vector (if y = TRUE
),
a list with elements "location"
and "scale"
containing the model matrices from the respective models
(if x = TRUE
).
Messner JW, Mayr GJ, Zeileis A (2016). Heteroscedastic Censored and Truncated Regression with crch. The R Journal, 8(1), 173--181. doi: 10.32614/RJ-2016-012 .
## data on alcohol and tobacco expenditures in Belgian households data("AlcoholTobacco", package = "htobit") AlcoholTobacco$persons <- with(AlcoholTobacco, adults + oldkids + youngkids) ## homoscedastic vs. heteroscedastic tobit model for budget share of alcohol m0 <- htobit(alcohol ~ age + log(expenditure) + persons, data = AlcoholTobacco) m1 <- update(m0, . ~ . | age + log(expenditure) + persons) ## comparison of the two models AIC(m0, m1)#> df AIC #> m0 5 -9496.072 #> m1 8 -9824.433#> df BIC #> m0 5 -9466.522 #> m1 8 -9777.154#>#>#> #>#>#> #>#> Likelihood ratio test #> #> Model 1: alcohol ~ age + log(expenditure) + persons #> Model 2: alcohol ~ age + log(expenditure) + persons | age + log(expenditure) + #> persons #> #Df LogLik Df Chisq Pr(>Chisq) #> 1 5 4753.0 #> 2 8 4920.2 3 334.36 < 2.2e-16 *** #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1## comparison with crch if(require("crch")) { c1 <- crch(alcohol ~ age + log(expenditure) + persons | age + log(expenditure) + persons, data = AlcoholTobacco, left = 0) cbind(coef(m1), coef(c1)) }#>#> [,1] [,2] #> (Intercept) -0.071762027 -0.071762027 #> age 0.002381390 0.002381390 #> log(expenditure) 0.006243513 0.006243513 #> persons -0.001763290 -0.001763290 #> (scale)_(Intercept) 0.175709476 0.175709475 #> (scale)_age 0.064390807 0.064390807 #> (scale)_log(expenditure) -0.277921386 -0.277921386 #> (scale)_persons -0.110616284 -0.110616284