Title: | Robust Estimation and Inference in Sample Selection Models |
---|---|
Description: | Package provides a set of tools for robust estimation and inference for models with sample selectivity and endogenous treatment model. For details, see Zhelonkin and Ronchetti (2021) <doi:10.18637/jss.v099.i04>. |
Authors: | Mikhail Zhelonkin, Marc G. Genton, Elvezio Ronchetti |
Maintainer: | Mikhail Zhelonkin <[email protected]> |
License: | GPL-2 |
Version: | 1.0 |
Built: | 2024-12-17 06:55:18 UTC |
Source: | CRAN |
Package provides a set of tools for robust estimation and inference for models with sample selectivity and endogenous treatment model.
Package: | ssmrob |
Type: | Package |
Version: | 1.0 |
Date: | 2021-08-18 |
License: | GPL-2 |
Mikhail Zhelonkin, Marc G. Genton, Elvezio Ronchetti
Maintainer: Mikhail Zhelonkin <[email protected]>
Heckman, J.J. (1979) Sample Selection Bias as a Specification Error. Econometrica, 47, p. 153-161.
Zhelonkin, M., Genton M.G., and Ronchetti, E. (2016) Robust Inference in Sample Selection Models. Journal of the Royal Statistical Society, Series B, 78, p. 805-827. doi:10.1111/rssb.12136
Zhelonkin, M., Ronchetti, E. (2021) Robust Analysis of Sample Selection Models through the R Package ssmrob. Journal of Statistical Software, 99, 4, p. 1-35. doi:10.18637/jss.v099.i04
ssmrob
, etregrob
, heckitrob
, heckit5rob
, selection
# Zhelonkin, Genton, Ronchetti (2016): page 823 data(MEPS2001) selectEq <- dambexp ~ age + female + educ + blhisp + totchr + ins outcomeEq <- lnambx ~ age + female + educ + blhisp + totchr + ins meps.fit <- ssmrob(selectEq, outcomeEq, data = MEPS2001, control = heckitrob.control(tcc = 3.2)) summary(meps.fit)
# Zhelonkin, Genton, Ronchetti (2016): page 823 data(MEPS2001) selectEq <- dambexp ~ age + female + educ + blhisp + totchr + ins outcomeEq <- lnambx ~ age + female + educ + blhisp + totchr + ins meps.fit <- ssmrob(selectEq, outcomeEq, data = MEPS2001, control = heckitrob.control(tcc = 3.2)) summary(meps.fit)
Returns the coefficients of the robust two-stage estimator for endogentous treatment model.
## S3 method for class 'etregrob' coef(object, ...)
## S3 method for class 'etregrob' coef(object, ...)
object |
object of class " |
... |
currently not used |
Returns a list of two vectors of parameters of two stages.
S |
coefficients of the selection equation. |
O |
coefficients of the outcome equation. |
Mikhail Zhelonkin
Returns the coefficients of the robust two-stage estimator for simple Heckman's selection model or switching regression model.
## S3 method for class 'heckit5rob' coef(object, ...)
## S3 method for class 'heckit5rob' coef(object, ...)
object |
object of class " |
... |
currently not used |
Returns a list of two (censored) or three (switching) vectors of parameters of two stages.
S |
coefficients of the selection equation. |
O |
coefficients of the outcome equation(s). |
Mikhail Zhelonkin, Marc G. Genton, Elvezio Ronchetti
Returns the coefficients of the robust two-stage estimator for simple Heckman's selection model or switching regression model.
## S3 method for class 'heckitrob' coef(object, ...)
## S3 method for class 'heckitrob' coef(object, ...)
object |
object of class " |
... |
currently not used |
Returns a list of two (censored) or three (switching) vectors of parameters of two stages.
S |
coefficients of the selection equation. |
O |
coefficients of the outcome equation(s). |
Mikhail Zhelonkin, Marc G. Genton, Elvezio Ronchetti
Computes a derivative of the inverse Mills ratio with respect to the parameter vector.
dLambdadSM(x, beta)
dLambdadSM(x, beta)
x |
vector of exogenous variables |
beta |
vector of parameters |
This function is necessary for computation of the asymptotic variance. In case of switching regressions the inverse Mills ratio term is different, and its derivative is computed in function dLambdadSM5
. It can be also used to compute the influence function of the two-stage estimator.
The gradient of the inverse Mills ratio is returned as a vector
Mikhail Zhelonkin, Marc G. Genton, Elvezio Ronchetti
Zhelonkin, M., Genton M.G., and Ronchetti, E. (2016) Robust Inference in Sample Selection Models. Journal of the Royal Statistical Society, Series B, 78, p. 805-827.
Computes a derivative of the inverse Mills ratio with respect to the parameter vector.
dLambdadSM5(x, beta)
dLambdadSM5(x, beta)
x |
vector of exogenous variables |
beta |
vector of parameters |
This function is necessary for computation of the asymptotic variance. In case of switching regressions the inverse Mills ratio term is different, and its derivative is computed in function dLambdadSM5
. It can also be used to compute the influence function of the two-stage estimator.
The gradient of the inverse Mills ratio is returned as a vector
Mikhail Zhelonkin, Marc G. Genton, Elvezio Ronchetti
Zhelonkin, M., Genton M.G., and Ronchetti, E. (2016) Robust Inference in Sample Selection Models. Journal of the Royal Statistical Society, Series B, 78, p. 805-827.
Computation of the asymptotic variance matrix of the robust Heckman's two-stage estimator for endogenous treatment model.
etreg2steprobVcov(y1vec, y2vec, x1Matr, x2Matr, eststage1, eststage2, eststage2sigma, weights = rep(1, nrow(y1vec)), t.c = 1.345)
etreg2steprobVcov(y1vec, y2vec, x1Matr, x2Matr, eststage1, eststage2, eststage2sigma, weights = rep(1, nrow(y1vec)), t.c = 1.345)
y1vec |
vector of endogenous variables of the selection stage |
y2vec |
vector of endogenous variables of the outcome stage |
x1Matr |
matrix of exogenous variables of the selection stage |
x2Matr |
matrix of exogenous variables of the outcome stage |
eststage1 |
object of class " |
eststage2 |
vector of the coefficients of the outcome stage |
eststage2sigma |
the robust scale estimate of the second stage regression |
weights |
robustness weights |
t.c |
tuning constant of the second stage |
The computation is made using the Huber (1967) - White (1980) sandwich estimator. In the computation of leverage weights the lambda's are assumed to be fixed.
Variance covariance matrix of the second stage estimator
Mikhail Zhelonkin
Huber, P.J. (1967) The Behavior of Maximum Likelihood Estimates under Nonstandard Conditions. Proceedings of the Fifth Berkeley Symposium on Mathematical Statistics and Probability; L.M. LeCam, J. Neyman (Eds.), Berkeley: University of California Press, p. 221-233.
White, H.J. (1980) A Heteroskedasticity-Consistent Covariance Matrix Estimator and a Direct Test for Heteroskedasticity. Econometrica, 48, p. 817-838.
Fits the endogenous treatment model using a robust two-stage estimator
etregrob(selection, outcome, data, control = heckitrob.control())
etregrob(selection, outcome, data, control = heckitrob.control())
selection |
formula, the selection equation |
outcome |
formula, the outcome equation |
data |
an optional data frame containing the variables in the model. If not found in data, the variables are taken from |
control |
a list of parameters for controlling the fitting process. The same list as for sample selection model |
Compute robust two-step estimates of the Endogenous Treatment Model. The robust probit is fitted in the first stage. In the second stage the Mallows type M-estimator is used instead of traditional OLS. The correction for endogeneity is made by means of control function, which is the inverse Mills ratio for a complete sample (see Maddala, 1983, p. 120-122).
The values of the tuning constants and the robustness weights can be modified in heckitrob.control
.
Object of class "etregrob".
coefficients |
a named vector of coefficients |
stage1 |
object of class |
stage2 |
object of class |
vcov |
variance matrix of the second stage |
sigma |
the standard error of the error term of the outcome equation |
CIMR |
inverse Mills ratio for the complete sample |
call |
the matched call |
method |
method of estimation, currently only "robust two-stage" is implemented |
converged |
logical. Did all the estimators converge? |
iterations |
list containing the numbers of iterations |
The treatment variable is automatically included in the formula for the second estimation step, i.e. one should not add the dependent variable from the selection equation in the formula of the outcome equation.
Mikhail Zhelonkin
Maddala G.S. (1983) Limited-Dependent and Qualitative Variables in Econometrics. Cambridge: Cambridge University Press.
Zhelonkin, M., Ronchetti, E. (2021) Robust Analysis of Sample Selection Models through the R Package ssmrob. Journal of Statistical Software, 99, 4, p. 1-35. doi:10.18637/jss.v099.i04
glmrob
, rlm
, ssmrob
, heckitrob.control
library(mvtnorm) set.seed(2) N <- 3000 beta1 <- c(1.0, 1.0, 0.75) beta2 <- c(1.5, 1.0, 0.5) alpha <- 1.25 x1 <- rmvnorm(N, mean = c(0, -1, 1), sigma = diag(c(1, 0.5, 1))) x2 <- x1 x2[, 3] <- rnorm(N, 1, 1) eps <- rmvnorm(N, mean = rep(0, 2), sigma = matrix(c(1, -0.7, -0.7, 1), 2, 2)) x1beta1 <- x1[, 1]*beta1[1] + x1[, 2]*beta1[2] + x1[, 3]*beta1[3] x2beta2 <- x2[, 1]*beta2[1] + x2[, 2]*beta2[2] + x2[, 3]*beta2[3] y1 <- ifelse(x1beta1 + eps[, 1] > 0, 1, 0) y2 <- x2beta2 + alpha*y1 + eps[,2] etm.ctrl <- heckitrob.control(weights.x1 = "hat", weights.x2 = "covMcd") etmsim.fit <- etregrob(y1 ~ x1, y2 ~ x2, control = etm.ctrl) summary(etmsim.fit)
library(mvtnorm) set.seed(2) N <- 3000 beta1 <- c(1.0, 1.0, 0.75) beta2 <- c(1.5, 1.0, 0.5) alpha <- 1.25 x1 <- rmvnorm(N, mean = c(0, -1, 1), sigma = diag(c(1, 0.5, 1))) x2 <- x1 x2[, 3] <- rnorm(N, 1, 1) eps <- rmvnorm(N, mean = rep(0, 2), sigma = matrix(c(1, -0.7, -0.7, 1), 2, 2)) x1beta1 <- x1[, 1]*beta1[1] + x1[, 2]*beta1[2] + x1[, 3]*beta1[3] x2beta2 <- x2[, 1]*beta2[1] + x2[, 2]*beta2[2] + x2[, 3]*beta2[3] y1 <- ifelse(x1beta1 + eps[, 1] > 0, 1, 0) y2 <- x2beta2 + alpha*y1 + eps[,2] etm.ctrl <- heckitrob.control(weights.x1 = "hat", weights.x2 = "covMcd") etmsim.fit <- etregrob(y1 ~ x1, y2 ~ x2, control = etm.ctrl) summary(etmsim.fit)
Calculate the fitted values of the endogenous treatment model using robust fit.
## S3 method for class 'etregrob' fitted(object, ...)
## S3 method for class 'etregrob' fitted(object, ...)
object |
object of class " |
... |
currently not used |
vector of fitted values
Mikhail Zhelonkin
Calculate the fitted values of the sample selection model using robust fit.
## S3 method for class 'heckit5rob' fitted(object, ...)
## S3 method for class 'heckit5rob' fitted(object, ...)
object |
object of class " |
... |
currently not used |
In case of truncated selection model one vector of fitted values is returned. In case of switching regression model a list, that contains two vectors corresponding to two regimes, is returned.
vector of fitted values or a list that contains two vectors of fitted values
Mikhail Zhelonkin, Marc G. Genton, Elvezio Ronchetti
Calculate the fitted values of the sample selection model using robust fit.
## S3 method for class 'heckitrob' fitted(object, ...)
## S3 method for class 'heckitrob' fitted(object, ...)
object |
object of class " |
... |
currently not used |
In case of truncated selection model one vector of fitted values is returned. In case of switching regression model a list, that contains two vectors corresponding to two regimes, is returned.
vector of fitted values or a list that contains two vectors of fitted values
Mikhail Zhelonkin, Marc G. Genton, Elvezio Ronchetti
Computation of the asymptotic variance matrix of the robust Heckman's two-stage estimator for truncated selection model.
heck2steprobVcov(y1vec, y2vec, x1Matr, x2Matr, eststage1, eststage2, eststage2sigma, weights = rep(1,nrow(y1vec)), t.c = 1.345)
heck2steprobVcov(y1vec, y2vec, x1Matr, x2Matr, eststage1, eststage2, eststage2sigma, weights = rep(1,nrow(y1vec)), t.c = 1.345)
y1vec |
vector of endogenous variables of the selection stage |
y2vec |
vector of endogenous variables of the outcome stage |
x1Matr |
matrix of exogenous variables of the selection stage |
x2Matr |
matrix of exogenous variables of the outcome stage |
eststage1 |
object of class " |
eststage2 |
vector of the coefficients of the outcome stage |
eststage2sigma |
the robust scale estimate of the second stage regression |
weights |
vector of robustness weights |
t.c |
tuning constant of the second stage |
The computation is made using the Huber (1967) - White (1980) sandwich estimator with Heckman (1979) correction. In the computation of leverage weights the lambda's are assumed to be fixed.
Variance covariance matrix of the second stage estimator
Mikhail Zhelonkin, Marc G. Genton, Elvezio Ronchetti
Heckman, J.J. (1979) Sample Selection Bias as a Specification Error. Econometrica, 47, p. 153-161.
Huber, P.J. (1967) The Behavior of Maximum Likelihood Estimates under Nonstandard Conditions. Proceedings of the Fifth Berkeley Symposium on Mathematical Statistics and Probability; L.M. LeCam, J. Neyman (Eds.), Berkeley: University of California Press, p. 221-233.
White, H.J. (1980) A Heteroskedasticity-Consistent Covariance Matrix Estimator and a Direct Test for Heteroskedasticity. Econometrica, 48, p. 817-838.
Computation of the asymptotic variance matrix of the robust Heckman's two-stage estimator for the second regime of switching regression model, i.e. when .
heck5twosteprobVcov(y1vec, y2vec, x1Matr, x2Matr, eststage1, eststage2, eststage2sigma, weights = rep(1,nrow(y1vec)), t.c = 1.345)
heck5twosteprobVcov(y1vec, y2vec, x1Matr, x2Matr, eststage1, eststage2, eststage2sigma, weights = rep(1,nrow(y1vec)), t.c = 1.345)
y1vec |
vector of endogenous variables of the selection stage |
y2vec |
vector of endogenous variables of the outcome stage |
x1Matr |
matrix of exogenous variables of the selection stage |
x2Matr |
matrix of exogenous variables of the outcome stage |
eststage1 |
object of class " |
eststage2 |
vector of the coefficients of the outcome stage |
eststage2sigma |
the robust scale estimate of the second stage regression |
weights |
vector of robustness weights |
t.c |
tuning constant of the second stage |
The computation is made using the Huber (1967) - White (1980) sandwich estimator with Heckman (1979) correction. In the computation of leverage weights the 's are assumed to be fixed.
Variance covariance matrix of the second stage estimator
Mikhail Zhelonkin, Marc G. Genton, Elvezio Ronchetti
Amemiya, T. (1984) Tobit Models: a Survey. Journal of Econometrics, 24, p. 3-61.
Heckman, J.J. (1979) Sample Selection Bias as a Specification Error. Econometrica, 47, p. 153-161.
Huber, P.J. (1967) The Behavior of Maximum Likelihood Estimates under Nonstandard Conditions. Proceedings of the Fifth Berkeley Symposium on Mathematical Statistics and Probability; L.M. LeCam, J. Neyman (Eds.), Berkeley: University of California Press, p. 221-233.
White, H.J. (1980) A Heteroskedasticity-Consistent Covariance Matrix Estimator and a Direct Test for Heteroskedasticity. Econometrica, 48, p. 817-838.
Fits the switching regression model with probit selection using a robust two-stage estimator
heckit5rob(selection, outcome1, outcome2, data, control = heckitrob.control())
heckit5rob(selection, outcome1, outcome2, data, control = heckitrob.control())
selection |
formula, the selection equation |
outcome1 |
formula, first outcome equation |
outcome2 |
formula, second outcome equation |
data |
an optional data frame containing the variables in the model. If not found in data, the variables are taken from |
control |
a list of parameters for controlling the fitting process |
Compute robust two-stage extimates of the switching regression model with probit selection. The robust probit is fitted in the first stage. In the second stage the Mallows type M-estimators are used.
The values of the tuning constants and the robustness weights can be modified in heckitrob.control
.
Object of class "heckit5rob".
coefficients |
a named vector of coefficients |
stage1 |
object of class |
stage21 |
object of class |
stage22 |
object of class |
vcov1 |
variance matrix of the second stage first regime |
vcov2 |
variance matrix of the second stage second regime |
sigma1 |
the standard error of the error term of the outcome equation when y_1=1 |
sigma2 |
the standard error of the error term of the outcome equation when y_1=0 |
IMR1 |
inverse Mills ratio for the case when y_1=1 |
IMR2 |
inverse Mills ratio for the case when y_1=0 |
call |
the matched call |
method |
method of estimation, currently only "robust two-stage" is implemented |
converged |
logical. Did all the estimators converge? |
iterations |
list containing the numbers of iterations |
Mikhail Zhelonkin, Marc G. Genton, Elvezio Ronchetti
Heckman, J.J. (1979) Sample Selection Bias as a Specification Error. Econometrica, 47, p. 153-161.
Zhelonkin, M., Genton M.G., and Ronchetti, E. (2016) Robust Inference in Sample Selection Models. Journal of the Royal Statistical Society, Series B, 78, p. 805-827. doi:10.1111/rssb.12136
Zhelonkin, M., Ronchetti, E. (2021) Robust Analysis of Sample Selection Models through the R Package ssmrob. Journal of Statistical Software, 99, 4, p. 1-35. doi:10.18637/jss.v099.i04
glmrob
, rlm
, ssmrob
, heckitrob
, heckitrob.control
## Not run: library(mvtnorm) set.seed(2) N <- 5000 beta1 <- c(0, 1.0, 1.0, 0.75) beta21 <- c(0, 1.5, 1.0, 0.5) beta22 <- c(1, -1.5, 1.0, 0.5) covm <- diag(3) covm[lower.tri(covm)] <- c(0.75, 0.5, 0.25) covm[upper.tri(covm)] <- covm[lower.tri(covm)] eps <- rmvnorm(N, rep(0, 3), covm) x1 <- rmvnorm(N, mean=c(0, -1, 1), sigma=diag(c(1, 0.5, 1))) x21 <- x1 x22 <- x1 x21[, 3] <- rnorm(N, 1, 1) x22[, 3] <- rnorm(N, 1, 1) x1beta1 <- beta1[1] + x1[, 1]*beta1[2] + x1[, 2]*beta1[3] + x1[, 3]*beta1[4] x21beta21 <- beta21[1] + x21[, 1]*beta21[2] + x21[, 2]*beta21[3] + x21[, 3]*beta21[4] x22beta22 <- beta22[1] + x22[, 1]*beta22[2] + x22[, 2]*beta22[3] + x22[, 3]*beta22[4] y1 <- ifelse(x1beta1 + eps[, 1] > 0, 1, 0) y2 <- ifelse(y1 > 0.5, x21beta21 + eps[, 2], x22beta22 + eps[, 3]) srsim.fit <- ssmrob(y1 ~ x1, list(y2 ~ x21, y2 ~ x22), control = heckitrob.control(weights.x1 = "hat", weights.x2 = "covMcd")) summary(srsim.fit) ## End(Not run)
## Not run: library(mvtnorm) set.seed(2) N <- 5000 beta1 <- c(0, 1.0, 1.0, 0.75) beta21 <- c(0, 1.5, 1.0, 0.5) beta22 <- c(1, -1.5, 1.0, 0.5) covm <- diag(3) covm[lower.tri(covm)] <- c(0.75, 0.5, 0.25) covm[upper.tri(covm)] <- covm[lower.tri(covm)] eps <- rmvnorm(N, rep(0, 3), covm) x1 <- rmvnorm(N, mean=c(0, -1, 1), sigma=diag(c(1, 0.5, 1))) x21 <- x1 x22 <- x1 x21[, 3] <- rnorm(N, 1, 1) x22[, 3] <- rnorm(N, 1, 1) x1beta1 <- beta1[1] + x1[, 1]*beta1[2] + x1[, 2]*beta1[3] + x1[, 3]*beta1[4] x21beta21 <- beta21[1] + x21[, 1]*beta21[2] + x21[, 2]*beta21[3] + x21[, 3]*beta21[4] x22beta22 <- beta22[1] + x22[, 1]*beta22[2] + x22[, 2]*beta22[3] + x22[, 3]*beta22[4] y1 <- ifelse(x1beta1 + eps[, 1] > 0, 1, 0) y2 <- ifelse(y1 > 0.5, x21beta21 + eps[, 2], x22beta22 + eps[, 3]) srsim.fit <- ssmrob(y1 ~ x1, list(y2 ~ x21, y2 ~ x22), control = heckitrob.control(weights.x1 = "hat", weights.x2 = "covMcd")) summary(srsim.fit) ## End(Not run)
Fits the sample selection model using a robust two-stage estimator
heckitrob(selection, outcome, data, control = heckitrob.control())
heckitrob(selection, outcome, data, control = heckitrob.control())
selection |
formula, the selection equation |
outcome |
formula, the outcome equation |
data |
an optional data frame containing the variables in the model. If not found in data, the variables are taken from |
control |
a list of parameters for controlling the fitting process |
Compute robust two-stage estimates of the Heckman's selection model. The robust probit is fitted in the first stage. In the second stage the Mallows type M-estimator is used.
The values of the tuning constants and the robustness weights can be modified in heckitrob.control
.
Object of class "heckitrob".
coefficients |
a named vector of coefficients |
stage1 |
object of class |
stage2 |
object of class |
vcov |
variance matrix of the second stage |
sigma |
the standard error of the error term of the outcome equation |
IMR1 |
inverse Mills ratio for the case when y_1=1 |
call |
the matched call |
method |
method of estimation, currently only "robust two-stage" is implemented |
converged |
logical. Did all the estimators converge? |
iterations |
list containing the numbers of iterations |
Mikhail Zhelonkin, Marc G. Genton, Elvezio Ronchetti
Cameron, C.A., Trivedi, P.K. (2009) Microeconometrics Using Stata. College Station, TX: Stata Press.
Heckman, J.J. (1979) Sample Selection Bias as a Specification Error. Econometrica, 47, p. 153-161.
Zhelonkin, M., Genton M.G., and Ronchetti, E. (2016) Robust Inference in Sample Selection Models. Journal of the Royal Statistical Society, Series B, 78, p. 805-827. doi:10.1111/rssb.12136
Zhelonkin, M., Ronchetti, E. (2021) Robust Analysis of Sample Selection Models through the R Package ssmrob. Journal of Statistical Software, 99, 4, p. 1-35. doi:10.18637/jss.v099.i04
glmrob
, rlm
, ssmrob
, heckitrob.control
, heckit5rob
, etregrob
# Zhelonkin, Genton, Ronchetti (2016): page 823 data(MEPS2001) selectEq <- dambexp ~ age + female + educ + blhisp + totchr + ins outcomeEq <- lnambx ~ age + female + educ + blhisp + totchr + ins meps.fit <- ssmrob(selectEq, outcomeEq, data = MEPS2001, control = heckitrob.control(tcc = 3.2)) summary(meps.fit)
# Zhelonkin, Genton, Ronchetti (2016): page 823 data(MEPS2001) selectEq <- dambexp ~ age + female + educ + blhisp + totchr + ins outcomeEq <- lnambx ~ age + female + educ + blhisp + totchr + ins meps.fit <- ssmrob(selectEq, outcomeEq, data = MEPS2001, control = heckitrob.control(tcc = 3.2)) summary(meps.fit)
Auxiliary function used for fitting the sample selection models. Contains control sequences, tuning constants and robustness weight functions.
heckitrob.control(acc = 1e-04, test.acc = "coef", maxit = 50, maxitO = 50, weights.x1 = c("none", "hat", "robCov", "covMcd"), weights.x2 = c("none", "hat", "robCov", "covMcd"), tcc = 1.345, t.c = 1.345)
heckitrob.control(acc = 1e-04, test.acc = "coef", maxit = 50, maxitO = 50, weights.x1 = c("none", "hat", "robCov", "covMcd"), weights.x2 = c("none", "hat", "robCov", "covMcd"), tcc = 1.345, t.c = 1.345)
acc |
positive convergence level |
test.acc |
only "coef" is currently implemented |
maxit |
integer giving the maximum number of iterations: selection equation |
maxitO |
integer giving the maximum number of iterations: outcome equation |
weights.x1 |
vector of robustness weights controlling for the leverage effect in the selection equation |
weights.x2 |
vector of robustness weights controlling for the leverage effect in the outcome equation |
tcc |
tuning constant c for Huber's psi-function for the selection stage |
t.c |
tuning constant c for Huber's psi-function for the outcome stage |
A list with the arguments as components.
Mikhail Zhelonkin, Marc G. Genton, Elvezio Ronchetti
The dataset is an extract from the Medical Expenditures Panel Survey. Sample of 3328 observations, with 526 zero expenditures. It was used for illustrative examples by Cameron and Trivedi (2009, Chapter 16).
data(MEPS2001)
data(MEPS2001)
A data frame with 3328 observations on the following 12 variables.
educ
Educational attainment, in years.
age
Age.
income
Income.
female
Logical, TRUE if female.
totchr
Number of chronic diseases.
age2
Age squared
ambexp
Ambulatory expenditures.
lambexp
Log ambulatory expenditures.
blhisp
Ethnicity. Logical, TRUE if black or hispanic.
dambexp
Logical, TRUE if the ambulatory expenditures are greater than zero.
lnambx
Log ambulatory expenditures, with zeros replacing NA's.
ins
Insurance status. Logical, TRUE if insured.
2001 Medical Expenditure Panel Survey by the Agency for Healthcare Research and Quality.
Cameron, C.A. and Trivedi, P.K. (2009) Microeconometrics Using Stata, College Station, TX: Stata Press.
data(MEPS2001) summary(MEPS2001)
data(MEPS2001) summary(MEPS2001)
M matrix of a linear regression M-estimator of Mallows type.
MmatrM(x, y, beta, sigma, t.c = 1.345, weights = 1)
MmatrM(x, y, beta, sigma, t.c = 1.345, weights = 1)
x |
matrix of explanatory variables |
y |
vector of dependent variables |
beta |
vector of parameters |
sigma |
robust scale estimate |
t.c |
tuning constant c for Huber's psi-function |
weights |
vector of robustness weights controlling for the leverage effects |
Computes the M matrix of the M-estimator of Mallows type. In current implementation only the Huber score function is available.
M matrix for the sandwich formula.
Mikhail Zhelonkin, Marc G. Genton, Elvezio Ronchetti
Create design matrix of endogenous treatment model
## S3 method for class 'etregrob' model.matrix(object, part = "outcome", ...)
## S3 method for class 'etregrob' model.matrix(object, part = "outcome", ...)
object |
object of class |
part |
character string indicating which matrix to extract: "outcome" for the outcome equation, "selection" for the selection equation. |
... |
currently not used |
If argument part
is "outcome"
, the design matrix of the outcome equation is returned.
If argument part
is "selection"
, the design matrix of the selection equation is returned.
Mikhail Zhelonkin
Create design matrix of switching regression model
## S3 method for class 'heckit5rob' model.matrix(object, part = "outcome", ...)
## S3 method for class 'heckit5rob' model.matrix(object, part = "outcome", ...)
object |
object of class |
part |
character string indicating which matrix to extract: "outcome" for the outcome equations, "selection" for the selection equation. |
... |
currently not used |
If argument part
is "outcome"
, the list containing design matrices of the outcome equations is returned.
stage21 |
design matrix for the first regime |
stage22 |
design matrix for the second regime |
If argument part
is "selection"
, the design matrix of the selection equation is returned.
Mikhail Zhelonkin
Create design matrix of sample selection model
## S3 method for class 'heckitrob' model.matrix(object, part = "outcome", ...)
## S3 method for class 'heckitrob' model.matrix(object, part = "outcome", ...)
object |
object of class |
part |
character string indicating which matrix to extract: "outcome" for the outcome equation, "selection" for the selection equation. |
... |
currently not used |
If argument part
is "outcome"
, the design matrix of the outcome equation is returned.
If argument part
is "selection"
, the design matrix of the selection equation is returned.
Mikhail Zhelonkin
Sample of 753 observations, with 325 truncated observations.
data(MROZ.RAW)
data(MROZ.RAW)
A data frame with 753 observations on the following 22 variables.
inlf
Logical, TRUE if in labor force.
hours
Hours worked by wife in 1975.
kidslt6
Number of young children, 5 year or younger.
kidsge6
Number of children greater than 6 years of age.
age
Wife's age.
educ
Education level in years.
wage
Average hourly earnings in 1975.
repwage
Wife's wage reported at the time of the 1976 interview.
hushrs
Husband's hours worked in 1975.
husage
Husband's age.
huseduc
Husband's education in years.
huswage
Husband's wage in 1975.
faminc
Family income in 1975.
mtr
Marginal tax rate facing the wife.
motheduc
Wife's mother's education in years.
fatheduc
Wife's father's education in years.
unem
Unemployment rate in county of residence.
city
Logical, TRUE if live in large city.
exper
Wife's labor market experience in years.
nwifeinc
Non-wife income, households's total money minus wife's labor income.
lwage
Wife's log-wage.
expersq
Wife's squared experience.
Mroz , T.A. (1987) The Sensitivity of an Empirical Model of Married Women's Hours of Work to Economic and Statistical Assumptions. Econometrica, 55, p. 765-799.
Wooldridge, J.M. (2002) Econometric Analysis of Cross Section and Panel Data, Cambridge MA: MIT Press.
data(MROZ.RAW) summary(MROZ.RAW)
data(MROZ.RAW) summary(MROZ.RAW)
Number of observations
## S3 method for class 'heckitrob' nobs(object, ...)
## S3 method for class 'heckitrob' nobs(object, ...)
object |
object of class |
... |
currently not used |
Mikhail Zhelonkin
etregrob
Object
Print an object generated by etregrob
## S3 method for class 'etregrob' print(x, digits = 4, ...)
## S3 method for class 'etregrob' print(x, digits = 4, ...)
x |
object of |
digits |
number of significant digits to be printed |
... |
currently not used |
Mikhail Zhelonkin
heckit5rob
Object
Print an object generated by ssmrob
## S3 method for class 'heckit5rob' print(x, digits = 4, ...)
## S3 method for class 'heckit5rob' print(x, digits = 4, ...)
x |
object returned from the |
digits |
number of significant digits to be printed |
... |
currently not used |
Mikhail Zhelonkin, Marc G. Genton, Elvezio Ronchetti
heckitrob
Object
Print an object generated by ssmrob
## S3 method for class 'heckitrob' print(x, digits = 4, ...)
## S3 method for class 'heckitrob' print(x, digits = 4, ...)
x |
object returned from the |
digits |
number of significant digits to be printed |
... |
currently not used |
Mikhail Zhelonkin, Marc G. Genton, Elvezio Ronchetti
summary.etregrob
Print a summary.etregrob
object
## S3 method for class 'summary.etregrob' print(x, digits = 4, ...)
## S3 method for class 'summary.etregrob' print(x, digits = 4, ...)
x |
Object of class |
digits |
number of nonzero digits after comma |
... |
currently not used |
Mikhail Zhelonkin
summary.heckit5rob
Print a summary.heckit5rob
object
## S3 method for class 'summary.heckit5rob' print(x, digits = 4, ...)
## S3 method for class 'summary.heckit5rob' print(x, digits = 4, ...)
x |
Object of class |
digits |
number of nonzero digits after comma |
... |
currently not used |
Mikhail Zhelonkin, Marc G. Genton, Elvezio Ronchetti
summary.heckitrob
Print a summary.heckitrob
object
## S3 method for class 'summary.heckitrob' print(x, digits = 4, ...)
## S3 method for class 'summary.heckitrob' print(x, digits = 4, ...)
x |
Object of class |
digits |
number of nonzero digits after comma |
... |
currently not used |
Mikhail Zhelonkin, Marc G. Genton, Elvezio Ronchetti
Score function of the Mallows-type M-estimator.
PsiMest(x, y, beta, sigma, t.c, weight)
PsiMest(x, y, beta, sigma, t.c, weight)
x |
vector of exogenous variables |
y |
scalar endogenous variable |
beta |
parameter vector |
sigma |
std.error |
t.c |
tuning constant of Huber Psi-function |
weight |
scalar weight on the exogenous variables |
Can be used to compute the influence function of the estimator. Also can be used to approximate the bias of the estimator.
score of the Psi-function
Mikhail Zhelonkin, Marc G. Genton, Elvezio Ronchetti
Hampel, Ronchetti, Rousseeuw, Stahel (1986). Robust Statistics: The Approach Based on Influence Functions. New York: Wiley.
Calculate the residuals of theendogenous treatment model using robust fit.
## S3 method for class 'etregrob' residuals(object, ...)
## S3 method for class 'etregrob' residuals(object, ...)
object |
object of class " |
... |
currently not used |
numeric vector of residuals.
Mikhail Zhelonkin
Calculate the residuals of the sample selection model using robust fit.
## S3 method for class 'heckit5rob' residuals(object, ...)
## S3 method for class 'heckit5rob' residuals(object, ...)
object |
object of class " |
... |
currently not used |
In case of truncated selection model one vector of residuals is returned. In case of switching regression model a list containing two vectors corresponding to two regimes is returned.
The numeric vector(s) of the residuals.
Mikhail Zhelonkin, Marc G. Genton, Elvezio Ronchetti
Calculate the residuals of the sample selection model using robust fit.
## S3 method for class 'heckitrob' residuals(object, ...)
## S3 method for class 'heckitrob' residuals(object, ...)
object |
object of class " |
... |
currently not used |
In case of truncated selection model one vector of residuals is returned. In case of switching regression model a list containing two vectors corresponding to two regimes is returned.
vector(s) of residuals.
Mikhail Zhelonkin, Marc G. Genton, Elvezio Ronchetti
Compute robust two-stage estimates of truncated selection model (Tobit-2) and switching regression model (Tobit-5).
ssmrob(selection, outcome, data, control = heckitrob.control())
ssmrob(selection, outcome, data, control = heckitrob.control())
selection |
formula, the selection equation |
outcome |
formula(s), the outcome equation(s) |
data |
an optional data frame containing the variables in the model. If not found in data, the variables are taken from |
control |
a list of parameters for controlling the fitting process |
Outcome equation may be a simple formula for the case of Heckman selection model, or a list of two formulas for the case of switching regressions.
Object of class "heckitrob" or object of class "heckit5rob".
Mikhail Zhelonkin, Marc G. Genton, Elvezio Ronchetti
Amemiya, T. (1984) Tobit Models: a Survey. Journal of Econometrics, 24, p. 3-61.
Heckman, J.J. (1979) Sample Selection Bias as a Specification Error. Econometrica, 47, p. 153-161.
Zhelonkin, M., Genton M.G., and Ronchetti, E. (2016) Robust Inference in Sample Selection Models. Journal of the Royal Statistical Society, Series B, 78, p. 805-827. doi:10.1111/rssb.12136
Zhelonkin, M., Ronchetti, E. (2021) Robust Analysis of Sample Selection Models through the R Package ssmrob. Journal of Statistical Software, 99, 4, p. 1-35. doi:10.18637/jss.v099.i04
# sample selection model (Tobit-2) # Zhelonkin, Genton, Ronchetti (2016): page 823 data(MEPS2001) selectEq <- dambexp ~ age + female + educ + blhisp + totchr + ins outcomeEq <- lnambx ~ age + female + educ + blhisp + totchr + ins meps.fit <- ssmrob(selectEq, outcomeEq, data = MEPS2001, control = heckitrob.control(tcc = 3.2)) summary(meps.fit) # switching regressions example (Tobit-5) ## Not run: library(mvtnorm) set.seed(2) N <- 5000 beta1 <- c(0, 1.0, 1.0, 0.75) beta21 <- c(0, 1.5, 1.0, 0.5) beta22 <- c(1, -1.5, 1.0, 0.5) covm <- diag(3) covm[lower.tri(covm)] <- c(0.75, 0.5, 0.25) covm[upper.tri(covm)] <- covm[lower.tri(covm)] eps <- rmvnorm(N, rep(0, 3), covm) x1 <- rmvnorm(N, mean=c(0, -1, 1), sigma=diag(c(1, 0.5, 1))) x21 <- x1 x22 <- x1 x21[, 3] <- rnorm(N, 1, 1) x22[, 3] <- rnorm(N, 1, 1) x1beta1 <- beta1[1] + x1[, 1]*beta1[2] + x1[, 2]*beta1[3] + x1[, 3]*beta1[4] x21beta21 <- beta21[1] + x21[, 1]*beta21[2] + x21[, 2]*beta21[3] + x21[, 3]*beta21[4] x22beta22 <- beta22[1] + x22[, 1]*beta22[2] + x22[, 2]*beta22[3] + x22[, 3]*beta22[4] y1 <- ifelse(x1beta1 + eps[, 1] > 0, 1, 0) y2 <- ifelse(y1 > 0.5, x21beta21 + eps[, 2], x22beta22 + eps[, 3]) srsim.fit <- ssmrob(y1 ~ x1, list(y2 ~ x21, y2 ~ x22), control = heckitrob.control(weights.x1 = "hat", weights.x2 = "covMcd")) summary(srsim.fit) ## End(Not run)
# sample selection model (Tobit-2) # Zhelonkin, Genton, Ronchetti (2016): page 823 data(MEPS2001) selectEq <- dambexp ~ age + female + educ + blhisp + totchr + ins outcomeEq <- lnambx ~ age + female + educ + blhisp + totchr + ins meps.fit <- ssmrob(selectEq, outcomeEq, data = MEPS2001, control = heckitrob.control(tcc = 3.2)) summary(meps.fit) # switching regressions example (Tobit-5) ## Not run: library(mvtnorm) set.seed(2) N <- 5000 beta1 <- c(0, 1.0, 1.0, 0.75) beta21 <- c(0, 1.5, 1.0, 0.5) beta22 <- c(1, -1.5, 1.0, 0.5) covm <- diag(3) covm[lower.tri(covm)] <- c(0.75, 0.5, 0.25) covm[upper.tri(covm)] <- covm[lower.tri(covm)] eps <- rmvnorm(N, rep(0, 3), covm) x1 <- rmvnorm(N, mean=c(0, -1, 1), sigma=diag(c(1, 0.5, 1))) x21 <- x1 x22 <- x1 x21[, 3] <- rnorm(N, 1, 1) x22[, 3] <- rnorm(N, 1, 1) x1beta1 <- beta1[1] + x1[, 1]*beta1[2] + x1[, 2]*beta1[3] + x1[, 3]*beta1[4] x21beta21 <- beta21[1] + x21[, 1]*beta21[2] + x21[, 2]*beta21[3] + x21[, 3]*beta21[4] x22beta22 <- beta22[1] + x22[, 1]*beta22[2] + x22[, 2]*beta22[3] + x22[, 3]*beta22[4] y1 <- ifelse(x1beta1 + eps[, 1] > 0, 1, 0) y2 <- ifelse(y1 > 0.5, x21beta21 + eps[, 2], x22beta22 + eps[, 3]) srsim.fit <- ssmrob(y1 ~ x1, list(y2 ~ x21, y2 ~ x22), control = heckitrob.control(weights.x1 = "hat", weights.x2 = "covMcd")) summary(srsim.fit) ## End(Not run)
Summarizes robust fit of endogenous treatment models.
## S3 method for class 'etregrob' summary(object, ...)
## S3 method for class 'etregrob' summary(object, ...)
object |
object of class " |
... |
currently not used |
object of class "summary.etregrob
"
Mikhail Zhelonkin
Summarize robust fit of Heckman selection model.
## S3 method for class 'heckit5rob' summary(object, ...)
## S3 method for class 'heckit5rob' summary(object, ...)
object |
object of class " |
... |
currently not used |
object of class "summary.heckitrob
" or object of class "summary.heckit5rob
"
Mikhail Zhelonkin, Marc G. Genton, Elvezio Ronchetti
heckitrob
; heckit5rob
; heck2steprobVcov
; heck5twosteprobVcov
Summarize robust fit of Heckman selection model.
## S3 method for class 'heckitrob' summary(object, ...)
## S3 method for class 'heckitrob' summary(object, ...)
object |
object of class " |
... |
currently not used |
object of class "summary.heckitrob
" or object of class "summary.heckit5rob
"
Mikhail Zhelonkin, Marc G. Genton, Elvezio Ronchetti
heckitrob
; heckit5rob
; heck2steprobVcov
; heck5twosteprobVcov
Extracts the variance covariance matrix of the robust endogenous treatment model fit
## S3 method for class 'etregrob' vcov(object, ...)
## S3 method for class 'etregrob' vcov(object, ...)
object |
object of class " |
... |
currently not used |
Variance covariance matrix of the second stage. Variance covariance matrix of the selection stage can be extracted using the vcov
function for the probit estimator, e.g. vcov(etregrob.object$stage1)
.
Mikhail Zhelonkin
Extract the variance covariance matrix of the robust sample selection model fit
## S3 method for class 'heckit5rob' vcov(object, ...)
## S3 method for class 'heckit5rob' vcov(object, ...)
object |
object of class " |
... |
currently not used |
Variance covariance matrix of the second stage. Variance covariance matrix of the selection stage can be extracted using the vcov
function for the probit estimator, e.g. vcov(heckitrob.object$stage1)
.
Mikhail Zhelonkin, Marc G. Genton, Elvezio Ronchetti
Extract the variance covariance matrix of the robust sample selection model fit
## S3 method for class 'heckitrob' vcov(object, ...)
## S3 method for class 'heckitrob' vcov(object, ...)
object |
object of class " |
... |
currently not used |
Variance covariance matrix of the second stage. Variance covariance matrix of the selection stage can be extracted using the vcov
function for the probit estimator, e.g. vcov(heckitrob.object$stage1)
.
Mikhail Zhelonkin, Marc G. Genton, Elvezio Ronchetti
Auxiliary function. Computation of the leverage weights based on robust Mahalanobis distance. For computation of location and scatter the MCD method is used.
x2weight.covMcd(xMat)
x2weight.covMcd(xMat)
xMat |
matrix of explanatory variables |
vector of weights
Mikhail Zhelonkin, Marc G. Genton, Elvezio Ronchetti
Auxiliary function. Computation of the leverage weights based on robust Mahalanobis distance. For computation of location and scatter the MVE method is used.
x2weight.robCov(xMat)
x2weight.robCov(xMat)
xMat |
matrix of explanatory variables |
vector of weights
Mikhail Zhelonkin, Marc G. Genton, Elvezio Ronchetti