Title: Sample Selection Models
Version: 2.0.1
Language: en-US
Author: Fernando de Souza Bastos [aut, cre], Wagner Barreto de Souza [aut]
Maintainer: Fernando de Souza Bastos <fernando.bastos@ufv.br>
Depends: R (≥ 3.6.0)
Imports: sn (≥ 2.1.0), numDeriv (≥ 2016.8-1.1), pracma (≥ 2.3.8), miscTools (≥ 0.6-26), Rdpack (≥ 2.4)
Suggests: knitr (≥ 1.24), testthat (≥ 3.0.0), maxLik (≥ 1.3-6), mvtnorm (≥ 1.0-11), sampleSelection (≥ 1.2-6), kableExtra (≥ 1.1.0), kfigr (≥ 1.2), ggplot2 (≥ 3.2.1), gridExtra (≥ 2.3)
Description: In order to facilitate the adjustment of the sample selection models existing in the literature, we created the 'ssmodels' package. Our package allows the adjustment of the classic Heckman model (Heckman (1976), Heckman (1979) <doi:10.2307/1912352>), and the estimation of the parameters of this model via the maximum likelihood method and two-step method, in addition to the adjustment of the Heckman-t models introduced in the literature by Marchenko and Genton (2012) <doi:10.1080/01621459.2012.656011> and the Heckman-Skew model introduced in the literature by Ogundimu and Hutton (2016) <doi:10.1111/sjos.12171>. We also implemented functions to adjust the generalized version of the Heckman model, introduced by Bastos, Barreto-Souza, and Genton (2021) <doi:10.5705/ss.202021.0068>, that allows the inclusion of covariables to the dispersion and correlation parameters, and a function to adjust the Heckman-BS model introduced by Bastos and Barreto-Souza (2020) <doi:10.1080/02664763.2020.1780570> that uses the Birnbaum-Saunders distribution as a joint distribution of the selection and primary regression variables. This package extends and complements existing R packages such as 'sampleSelection' (Toomet and Henningsen, 2008) and 'ssmrob' (Zhelonkin et al., 2016), providing additional robust and flexible sample selection models.
License: GPL-2 | GPL-3 [expanded from: GPL (≥ 2)]
Encoding: UTF-8
LazyData: true
VignetteBuilder: knitr
RoxygenNote: 7.3.2
RdMacros: Rdpack
BugReports: https://github.com/fsbmat-ufv/ssmodels/issues
Config/testthat/edition: 3
URL: https://fsbmat-ufv.github.io/ssmodels/
NeedsCompilation: no
Packaged: 2025-06-02 01:50:20 UTC; Fernando
Repository: CRAN
Date/Publication: 2025-06-02 12:50:01 UTC

ssmodels: Sample Selection Models in R

Description

The ssmodels package provides functions to fit data affected by sample selection bias. It includes several extensions of the classical Heckman selection model, allowing for different assumptions about the joint distribution of the selection and outcome equations.

Details

The following models are implemented:

HeckmanCL

Classic Heckman model (Tobit-2).

HeckmantS

Heckman model with Student's t-distribution.

HeckmanSK

Heckman model with Skew-Normal distribution.

HeckmanBS

Heckman model with Birnbaum-Saunders distribution.

HeckmanGe

Generalized Heckman model with covariates in the dispersion and correlation structures.

The package also includes helper functions for computing Inverse Mills Ratios (IMR), post-processing parameter vectors, and two-step initial value estimation.

Author(s)

Fernando de Souza Bastos, Wagner Barreto de Souza

References

James J Heckman (1976). “The common structure of statistical models of truncation, sample selection and limited dependent variables and a simple estimator for such models.” In Annals of Economic and Social Measurement, Volume 5, number 4, 475–492. NBER.

James J Heckman (1979). “Sample selection bias as a specification error.” Econometrica: Journal of the econometric society, 153–161.

Thomas A Mroz (1987). “The sensitivity of an empirical model of married women's hours of work to economic and statistical assumptions.” Econometrica: Journal of the Econometric Society, 765–799.

Ott Toomet, Arne Henningsen (2008). “Sample Selection Models in R: Package sampleSelection.” Journal of Statistical Software, 27(7). https://www.jstatsoft.org/article/view/v027i07.

Yulia V Marchenko, Marc G Genton (2012). “A Heckman selection-t model.” Journal of the American Statistical Association, 107(497), 304–317.

Emmanuel O Ogundimu, Jane L Hutton (2016). “A Sample Selection Model with Skew-normal Distribution.” Scandinavian Journal of Statistics, 43(1), 172–190.

Mikhail Zhelonkin, Marc G Genton, Elvezio Ronchetti (2016). “Robust inference in sample selection models.” Journal of the Royal Statistical Society: Series B (Statistical Methodology), 78(4), 805–827.

Mikhail Zhelonkin, Marc G. Genton, Elvezio Ronchetti (2019). ssmrob: Robust Estimation and Inference in Sample Selection Models. R package version 0.7, https://CRAN.R-project.org/package=ssmrob.

Emmanuel O Ogundimu, Gary S Collins (2019). “A robust imputation method for missing responses and covariates in sample selection models.” Statistical methods in medical research, 28(1), 102–116.

Fernando de Souza Bastos, Wagner Barreto-Souza (2020). “Birnbaum–Saunders sample selection model.” Journal of Applied Statistics.

Fernando de Souza Bastos, Wagner Barreto-Souza, Marc G Genton (2022). “A Generalized Heckman Model With Varying Sample Selection Bias and Dispersion Parameters.” Statistica Sinica.

See Also

HeckmanCL, HeckmantS, HeckmanSK, HeckmanBS, HeckmanGe


Two-Step Method for Parameter Estimation of the Classical Heckman Model

Description

Estimates the parameters of the classical Heckman sample selection model using the two-step estimation method.

Usage

HCinitial(selection, outcome, data = sys.frame(sys.parent()))

Arguments

selection

A formula specifying the selection equation.

outcome

A formula specifying the outcome equation.

data

A data frame containing the variables in the model.

Details

This function implements the two-step approach proposed by Heckman (1979) to estimate the parameters of the classic sample selection model. It is particularly useful for obtaining initial values for maximum likelihood estimation (MLE).

In the first step, a probit model is fitted to the selection equation to estimate the probability of selection. The second step involves estimating a linear regression of the outcome equation for the observed (selected) data, incorporating the inverse Mills ratio (IMR) as an additional regressor to correct for sample selection bias.

The function also estimates:

Value

A named numeric vector containing:

References

James J Heckman (1979). “Sample selection bias as a specification error.” Econometrica: Journal of the econometric society, 153–161.

Examples

data(MEPS2001)
attach(MEPS2001)
selectEq <- dambexp ~ age + female + educ + blhisp + totchr + ins + income
outcomeEq <- lnambx ~ age + female + educ + blhisp + totchr + ins
HCinitial(selectEq, outcomeEq, data = MEPS2001)


Heckman-BS Model Fit Function

Description

Fits the Heckman Sample Selection Model based on the Birnbaum-Saunders (BS) bivariate distribution. This function implements the maximum likelihood estimation of the model parameters.

Usage

HeckmanBS(selection, outcome, data = sys.frame(sys.parent()), start = NULL)

Arguments

selection

A formula object specifying the selection equation.

outcome

A formula object specifying the primary outcome equation.

data

A data frame containing the variables in the model.

start

An optional numeric vector of initial parameter values. If not provided, default values are used.

Details

The function estimates the parameters of the Heckman-BS model, which extends the classical Heckman model by assuming that the error terms follow a bivariate Birnbaum-Saunders distribution. The model has the same number of parameters as the classical Heckman model, including the correlation coefficient between the error terms. The optimization is performed using the optim function with the BFGS method.

The estimated quantities include:

Additional outputs include measures of model fit, standard errors (approximated by the square root of the diagonal of the inverse Fisher information matrix), and diagnostic information.

Value

A list containing:

References

There are no references for Rd macro ⁠\insertAllCites⁠ on this help page.

Examples

data(MEPS2001)
attach(MEPS2001)
selectEq <- dambexp ~ age + female + educ + blhisp + totchr + ins + income
outcomeBS <- ambexp ~ age + female + educ + blhisp + totchr + ins
HeckmanBS(selectEq, outcomeBS, data = MEPS2001)


Classic Heckman Model Fit Function

Description

Fits the classical Heckman sample selection model using Maximum Likelihood Estimation (MLE). Initial parameter estimates are obtained via the two-step method.

Usage

HeckmanCL(selection, outcome, data = sys.frame(sys.parent()), start = NULL)

Arguments

selection

A formula specifying the selection equation.

outcome

A formula specifying the primary outcome equation.

data

A data frame containing the variables in the model.

start

An optional numeric vector of initial parameter values. If not provided, default values are used.

Details

This function estimates the parameters of the classical Heckman sample selection model via MLE, accounting for potential sample selection bias. It uses the optim function with the BFGS method to find the parameter estimates that maximize the log-likelihood function. The initial values for optimization are obtained using the two-step Heckman method.

The function returns a rich set of results, including:

Value

A list containing:

References

James J Heckman (1979). “Sample selection bias as a specification error.” Econometrica: Journal of the econometric society, 153–161.

Examples

data(MEPS2001)
attach(MEPS2001)
selectEq <- dambexp ~ age + female + educ + blhisp + totchr + ins + income
outcomeEq <- lnambx ~ age + female + educ + blhisp + totchr + ins
HeckmanCL(selectEq, outcomeEq, data = MEPS2001)


Generalized Heckman Model Estimation

Description

Fits a generalized Heckman sample selection model that allows for heteroskedasticity in the outcome equation and correlation of the error terms depending on covariates. The estimation is performed via Maximum Likelihood using the BFGS algorithm.

Usage

HeckmanGe(
  selection,
  outcome,
  outcomeS,
  outcomeC,
  data = sys.frame(sys.parent()),
  start = NULL
)

Arguments

selection

A formula specifying the selection equation.

outcome

A formula specifying the outcome equation.

outcomeS

A formula or matrix specifying covariates for the scale (variance) model.

outcomeC

A formula or matrix specifying covariates for the correlation model.

data

A data frame containing the variables in the model.

start

An optional numeric vector with starting values for the optimization.

Details

This function extends the classical Heckman selection model by incorporating models for the error term's variance (scale) and the correlation between the selection and outcome equations. The scale model (outcomeS) allows the error variance of the outcome equation to depend on covariates, while the correlation model (outcomeC) allows the error correlation to vary with covariates.

The optimization is initialized with default or user-supplied starting values, and the results include robust standard errors derived from the inverse of the observed Fisher information matrix.

Value

A list containing:

References

Fernando de Souza Bastos, Wagner Barreto-Souza, Marc G Genton (2022). “A Generalized Heckman Model With Varying Sample Selection Bias and Dispersion Parameters.” Statistica Sinica.

Examples

## Not run: 
data(MEPS2001)
attach(MEPS2001)
selectEq <- dambexp ~ age + female + educ + blhisp + totchr + ins + income
outcomeEq <- lnambx ~ age + female + educ + blhisp + totchr + ins
outcomeS <- ~ educ + income
outcomeC <- ~ blhisp + female
HeckmanGe(selectEq, outcomeEq, outcomeS = outcomeS, outcomeC = outcomeC, data = MEPS2001)

## End(Not run)


Skew-Normal Sample Selection Model Fit Function

Description

Fits a sample selection model based on the Skew-Normal distribution using Maximum Likelihood Estimation (MLE). This model allows for asymmetry in the distribution of the outcome variable's error term, addressing potential skewness.

Usage

HeckmanSK(
  selection,
  outcome,
  data = sys.frame(sys.parent()),
  lambda,
  start = NULL
)

Arguments

selection

A formula specifying the selection equation.

outcome

A formula specifying the outcome equation.

data

A data frame containing the variables.

lambda

Initial start value for the skewness parameter (lambda).

start

Optional numeric vector of initial parameter values.

Details

The function implements MLE for a sample selection model where the outcome equation's errors follow a Skew-Normal distribution, as proposed in Ogundimu and Hutton (2016). The optimization is performed via the BFGS algorithm.

The results include estimates for:

Value

A list containing:

References

Emmanuel O Ogundimu, Jane L Hutton (2016). “A Sample Selection Model with Skew-normal Distribution.” Scandinavian Journal of Statistics, 43(1), 172–190.

Examples

data("Mroz87")
attach(Mroz87)
selectEq <- lfp ~ huswage + kids5 + mtr + fatheduc + educ + city
outcomeEq <- log(wage) ~ educ + city
HeckmanSK(selectEq, outcomeEq, data = Mroz87, lambda = -1.5)


Heckman-t Model Fit Function

Description

Fits a sample selection model based on the Student's t-distribution, extending the classical Heckman model to account for heavy-tailed error terms. The estimation is performed via Maximum Likelihood using the BFGS algorithm.

Usage

HeckmantS(selection, outcome, data = sys.frame(sys.parent()), df, start = NULL)

Arguments

selection

A formula specifying the selection equation.

outcome

A formula specifying the outcome equation.

data

A data frame containing the variables in the model.

df

Initial value for the degrees of freedom parameter of the t-distribution.

start

Optional numeric vector of initial parameter values.

Details

The function implements the Heckman sample selection model using the Student's t-distribution for the error terms, as proposed by Marchenko and Genton (2012). This extension allows for robustness against outliers and heavy-tailed distributions. Initial parameter values can be specified by the user or default to standard starting values.

Value

A list containing:

References

Yulia V Marchenko, Marc G Genton (2012). “A Heckman selection-t model.” Journal of the American Statistical Association, 107(497), 304–317.

Examples

data(MEPS2001)
attach(MEPS2001)
selectEq <- dambexp ~ age + female + educ + blhisp + totchr + ins + income
outcomeEq <- lnambx ~ age + female + educ + blhisp + totchr + ins
HeckmantS(selectEq, outcomeEq, data = MEPS2001, df = 12)


Inverse Mills Ratio (IMR) Calculation

Description

Computes the column vector of the Inverse Mills Ratio (IMR) from a Probit selection equation.

Usage

IMR(selection, data = sys.frame(sys.parent()))

Arguments

selection

A formula specifying the selection equation.

data

A data frame containing the variables in the model.

Details

This function fits a Probit model to the provided selection equation and returns the Inverse Mills Ratio (IMR) for each observation. The IMR is useful for correcting sample selection bias in regression models, following the classical Heckman approach.

Value

A numeric matrix with one column containing the IMR values for each observation.

Examples

data(MEPS2001)
attach(MEPS2001)
selectEq <- dambexp ~ age + female + educ + blhisp + totchr + ins + income
IMR(selectEq, data = MEPS2001)


Medical Expenditure Panel Survey

Description

The MEPS is a set of large-scale surveys of families, individuals and their medical providers (doctors, hospitals, pharmacies, etc.) in the United States. It has data on the health services Americans use, how often they use them, the cost of these services and how they are paid, as well as data on the cost and reach of health insurance available to American workers. The sample is restricted to persons aged between 21 and 64 years and contains a variable response with 3328 observations of outpatient costs, of which 526 (15.8%) correspond to unobserved expenditure values and identified as zero expenditure for adjustment of the models. It also includes the following explanatory variables:

Usage

MEPS2001

Format

An object of class data.frame with 3328 rows and 22 columns.

Source

2001 Medical Expenditure Panel Survey by the Agency for Healthcare Research and Quality.

References

Cameron A Colin, Pravin K Trivedi (2009). “Microeconometrics using STATA.” Lakeway Drive, TX: Stata Press Books.

Mikhail Zhelonkin, Marc G. Genton, Elvezio Ronchetti (2019). ssmrob: Robust Estimation and Inference in Sample Selection Models. R package version 0.7, https://CRAN.R-project.org/package=ssmrob.

Ott Toomet, Arne Henningsen (2008). “Sample Selection Models in R: Package sampleSelection.” Journal of Statistical Software, 27(7). https://www.jstatsoft.org/article/view/v027i07.

Examples

data(MEPS2001)
attach(MEPS2001)
hist(lnambx)
selectEq <- dambexp ~ age + female + educ + blhisp + totchr + ins + income
outcomeEq <- lnambx ~ age + female + educ + blhisp + totchr + ins
HeckmanCL(selectEq, outcomeEq, data = MEPS2001)

U.S. Women's Labor Force Participation

Description

The Mroz87 data frame contains data about 753 married women. These data are collected within the "Panel Study of Income Dynamics" (PSID). Of the 753 observations, the first 428 are for women with positive hours worked in 1975, while the remaining 325 observations are for women who did not work for pay in 1975. A more complete discussion of the data is found in Mroz (1987). It also includes the following explanatory variables:

Usage

Mroz87

Format

An object of class data.frame with 753 rows and 22 columns.

Source

PSID Staff, The Panel Study of Income Dynamics, Institute for Social ResearchPanel Study of Income Dynamics, University of Michigan, https://psidonline.isr.umich.edu/

References

Thomas A Mroz (1987). “The sensitivity of an empirical model of married women's hours of work to economic and statistical assumptions.” Econometrica: Journal of the Econometric Society, 765–799.

Mikhail Zhelonkin, Marc G. Genton, Elvezio Ronchetti (2019). ssmrob: Robust Estimation and Inference in Sample Selection Models. R package version 0.7, https://CRAN.R-project.org/package=ssmrob.

Ott Toomet, Arne Henningsen (2008). “Sample Selection Models in R: Package sampleSelection.” Journal of Statistical Software, 27(7). https://www.jstatsoft.org/article/view/v027i07.

Jeffrey M Wooldridge (2016). Introductory econometrics: A modern approach. Nelson Education.

Examples

# Wooldridge(2016): page 247
data(Mroz87)
attach(Mroz87)
Mroz87$lwage <- ifelse(Mroz87$wage>0,log(Mroz87$wage), NA)
selectEq <- lfp ~ nwifeinc + educ + exper + I(exper^2) + age + kids5 + kids618
outcomeEq <- lwage ~ educ + exper + I(exper^2)
outcomeS <- cbind(educ, exper)
outcomeC <- 1
outcomeBS <- wage ~ educ + exper + I(exper^2)
outcomeBS <- wage ~ educ + exper + I(exper^2)
HeckmanCL(selectEq, outcomeEq, data = Mroz87)
HeckmanBS(selectEq, outcomeBS, data = Mroz87)
HeckmanSK(selectEq, outcomeEq, data = Mroz87, lambda = 1)
HeckmantS(selectEq, outcomeEq, data = Mroz87, df=5)
HeckmanGe(selectEq, outcomeEq, outcomeS, outcomeC, data = Mroz87)


Panel Study of Income Dynamics

Description

The data come from the Panel Study of Income Dynamics, years 1981 to 1992 (also contains earnings data from 1980). The sample consists of 579 white females, who were followed over the considered period. In total, there are 6,948 observations over the 12-year period (1981-1992). This data frame contains the following columns:

Usage

PSID2

Format

An object of class data.frame with 6948 rows and 13 columns.

Source

https://simba.isr.umich.edu/

References

Anastasia Semykina, Jeffrey M Wooldridge (2013). “Estimation of dynamic panel data models with sample selection.” Journal of Applied Econometrics, 28(1), 47–61.

Mikhail Zhelonkin, Marc G. Genton, Elvezio Ronchetti (2019). ssmrob: Robust Estimation and Inference in Sample Selection Models. R package version 0.7, https://CRAN.R-project.org/package=ssmrob.

Ott Toomet, Arne Henningsen (2008). “Sample Selection Models in R: Package sampleSelection.” Journal of Statistical Software, 27(7). https://www.jstatsoft.org/article/view/v027i07.

Examples

data(PSID2)
attach(PSID2)
hist(Lnw)
selectEq <- s ~ educ+ age+ children+ year
outcomeEq <- Lnw ~ educ+ age+ children
HCinitial(selectEq,outcomeEq, data = PSID2)
#Note that the estimated value of rho by the two-step
#method is greater than 1
summary(HeckmanGe(selectEq,outcomeEq, 1, 1, data = PSID2))


RAND Health Insurance Experiment

Description

'The RAND Health Insurance Experiment (RAND HIE) was a comprehensive study of health care cost, utilization and outcome in the United States. It is the only randomized study of health insurance, and the only study which can give definitive evidence as to the causal effects of different health insurance plans. For more information about the database visit: https://en.wikipedia.org/w/index.php?title=RAND_Health_Insurance_Experiment&oldid=110166949 accessed september 09, 2019). This data frame contains the following columns:

Usage

RandHIE

Format

An object of class data.frame with 20190 rows and 45 columns.

Source

https://cameron.econ.ucdavis.edu/mmabook/mmadata.html

References

A Colin Cameron, Pravin K Trivedi (2005). Microeconometrics: methods and applications. Cambridge university press.

Mikhail Zhelonkin, Marc G. Genton, Elvezio Ronchetti (2019). ssmrob: Robust Estimation and Inference in Sample Selection Models. R package version 0.7, https://CRAN.R-project.org/package=ssmrob.

Ott Toomet, Arne Henningsen (2008). “Sample Selection Models in R: Package sampleSelection.” Journal of Statistical Software, 27(7). https://www.jstatsoft.org/article/view/v027i07.

Wikipedia contributors (2019). “RAND Health Insurance Experiment — Wikipedia, The Free Encyclopedia.” https://en.wikipedia.org/w/index.php?title=RAND_Health_Insurance_Experiment&oldid=909771077. [Online; accessed 9-September-2019].

Examples

##Cameron and Trivedi (2005): Section 16.6
data(RandHIE)
subsample <- RandHIE$year == 2 & !is.na( RandHIE$educdec )
selectEq <- binexp ~ logc + idp + lpi + fmde + physlm + disea +
  hlthg + hlthf + hlthp + linc + lfam + educdec + xage + female +
  child + fchild + black
  outcomeEq <- lnmeddol ~ logc + idp + lpi + fmde + physlm + disea +
  hlthg + hlthf + hlthp + linc + lfam + educdec + xage + female +
  child + fchild + black
  cameron <- HeckmanCL(selectEq, outcomeEq, data = RandHIE[subsample, ])
  summary(cameron)


Extract Model Components for Selection Models

Description

This internal utility function extracts key components—such as model frames, matrices, and response variables—from formulas and a data set. It is used by models like HeckmanCL, HeckmanGe, HeckmanSK, HeckmanBS, and HeckmantS. Additionally, it can handle covariate matrices for modeling dispersion (sigma) and correlation (rho) structures.

Usage

extract_model_components(
  selection,
  outcome,
  data,
  outcomeS = NULL,
  outcomeC = NULL,
  drop.levels = TRUE
)

Arguments

selection

A formula for the selection equation.

outcome

A formula for the outcome equation.

data

A data frame containing all variables.

outcomeS

Optional formula or matrix for the dispersion model (sigma).

outcomeC

Optional formula or matrix for the correlation model (rho).

drop.levels

Logical. If TRUE, drops unused factor levels.

Details

If provided, outcomeS and outcomeC can be formulas or matrices for modeling dispersion and correlation structures, respectively. The function ensures that the selection equation response is binary.

Value

A list with the following components:

XS

Model matrix for the selection equation.

YS

Response vector for the selection equation.

NXS

Number of covariates in the selection model.

XO

Model matrix for the outcome equation.

YO

Response vector for the outcome equation.

NXO

Number of covariates in the outcome model.

Msigma

Matrix for the dispersion model (or NULL if not provided).

NE

Number of covariates for the dispersion model (0 if not provided).

Mrho

Matrix for the correlation model (or NULL if not provided).

NV

Number of covariates for the correlation model (0 if not provided).

YSLevels

Factor levels of the binary selection response.


US National Health and Nutrition Examination Study

Description

The US National Health and Nutrition Examination Study (NHANES) is a survey data collected by the US National Center for Health Statistics. The survey data dates back to 1999, where individuals of all ages are interviewed in their home annually and complete the health examination component of the survey. The study variables include demographic variables (e.g. age and annual household income), physical measurements (e.g. BMI – body mass index), health variables (e.g. diabetes status), and lifestyle variables (e.g. smoking status). This data frame contains the following columns:

Usage

nhanes

Format

An object of class data.frame with 9643 rows and 9 columns.

Source

https://wwwn.cdc.gov/nchs/nhanes/ContinuousNhanes/Default.aspx?BeginYear=2003

References

Emmanuel O Ogundimu, Gary S Collins (2019). “A robust imputation method for missing responses and covariates in sample selection models.” Statistical methods in medical research, 28(1), 102–116.

Roderick J Little, Nanhua Zhang (2011). “Subsample ignorable likelihood for regression analysis with missing data.” Journal of the Royal Statistical Society: Series C (Applied Statistics), 60(4), 591–605.

Mikhail Zhelonkin, Marc G. Genton, Elvezio Ronchetti (2019). ssmrob: Robust Estimation and Inference in Sample Selection Models. R package version 0.7, https://CRAN.R-project.org/package=ssmrob.

Ott Toomet, Arne Henningsen (2008). “Sample Selection Models in R: Package sampleSelection.” Journal of Statistical Software, 27(7). https://www.jstatsoft.org/article/view/v027i07.

Examples

data("nhanes")
attach(nhanes)
hist(Income, prob= TRUE, breaks = seq(1, 99, 0.5), xlim = c(1,10),
ylim = c(0,0.35), main = "Histogram of Income", xlab = "Category")
data2 <- subset(nhanes, !is.na(sbp))
data3 <- subset(data2, !is.na(bmi))
attach(data3)
data <- data3
data$YS <- ifelse(is.na(data$Income),0,1)
data$educ <- ifelse(data$educ<=2,0,1)
attach(data)
selectionEq <- YS~age+gender+educ+race
outcomeEq   <- sbp~age+gender+educ+bmi


Post-process Parameter Vector for Generalized Heckman Models

Description

Internal helper function that assigns meaningful names to a vector of estimated parameters and applies transformations to sigma and rho parameters to obtain interpretable estimates.

Usage

postprocess_theta(theta_par, NXS, NXO, NE, NV, XS, XO, outcomeS, outcomeC)

Arguments

theta_par

A numeric vector containing the estimated parameters.

NXS

Integer. Number of covariates in the selection equation.

NXO

Integer. Number of covariates in the outcome equation.

NE

Integer. Number of covariates (or 1 for intercept-only) in the scale model.

NV

Integer. Number of covariates (or 1 for intercept-only) in the correlation model.

XS

Design matrix for the selection equation (used for naming).

XO

Design matrix for the outcome equation (used for naming).

outcomeS

Design matrix or variable for the scale (variance) model.

outcomeC

Design matrix or variable for the correlation model.

Details

The parameter vector theta_par is structured as follows:

For interpretation, the function applies:

Value

A named numeric vector with:


Heckman's Two-Step Method

Description

Estimates the parameters of the classical Heckman selection model using the two-step method. The first step fits a probit model for the selection equation. In the second step, the inverse Mills ratio (IMR) is included as an additional regressor in the outcome equation.

Usage

step2(YS, XS, YO, XO)

Arguments

YS

A binary vector indicating selection (1 if observed, 0 otherwise).

XS

A matrix of covariates for the selection equation.

YO

A numeric vector representing the outcome variable of interest.

XO

A matrix of covariates for the outcome equation.

Details

This function implements the two-step estimation procedure of the classical Heckman model. In the first step, a probit model is estimated to predict the selection indicator YS using the selection covariates XS. The IMR is calculated from this model. In the second step, an ordinary least squares (OLS) regression of the observed outcome YO on XO and the IMR is performed for the uncensored observations (YS == 1).

The function also calculates:

Value

A numeric vector containing the parameter estimates from the two-step Heckman model:

References

There are no references for Rd macro ⁠\insertAllCites⁠ on this help page.

Examples

data(MEPS2001)
attach(MEPS2001)
YS <- dambexp
XS <- cbind(age, female, educ, blhisp, totchr, ins)
YO <- lnambx
XO <- cbind(age, female, educ, blhisp, totchr, ins, income)
step2(YS, XS, YO, XO)


Summary of Birnbaum-Saunders Heckman Model

Description

Prints a detailed summary of the parameter estimates and model fit statistics for an object of class HeckmanBS.

Usage

## S3 method for class 'HeckmanBS'
summary(object, ...)

Arguments

object

An object of class HeckmanBS, containing the fitted model results.

...

Additional arguments (currently unused).

Details

This method provides a summary of the maximum likelihood estimation results for the Heckman sample selection model with Birnbaum-Saunders errors. It includes separate coefficient tables for:

Model fit criteria such as the log-likelihood, AIC, and BIC are also reported.

Value

Prints to the console:

Invisibly returns NULL.

See Also

HeckmanBS

Examples

## Not run: 
data(MEPS2001)
attach(MEPS2001)
selectEq <- dambexp ~ age + female + educ + blhisp + totchr + ins + income
outcomeEq <- ambexp ~ age + female + educ + blhisp + totchr + ins
model <- HeckmanBS(selectEq, outcomeEq, data = MEPS2001)
summary(model)

## End(Not run)


Summary of Classic Heckman Model

Description

Prints a detailed summary of the parameter estimates and model fit statistics for an object of class HeckmanCL.

Usage

## S3 method for class 'HeckmanCL'
summary(object, ...)

Arguments

object

An object of class HeckmanCL, containing the fitted model results.

...

Additional arguments (currently unused).

Details

This method displays the maximum likelihood estimation results for the classical Heckman sample selection model. It includes separate coefficient tables for:

Additionally, it reports the model fit statistics (log-likelihood, AIC, BIC, and number of observations).

Value

Prints to the console:

Invisibly returns NULL.

See Also

HeckmanCL

Examples

## Not run: 
data(MEPS2001)
attach(MEPS2001)
selectEq <- dambexp ~ age + female + educ + blhisp + totchr + ins + income
outcomeEq <- lnambx ~ age + female + educ + blhisp + totchr + ins
model <- HeckmanCL(selectEq, outcomeEq, data = MEPS2001)
summary(model)

## End(Not run)


Summary of Generalized Heckman Model

Description

Prints a detailed summary of the parameter estimates and model fit statistics for an object of class HeckmanGe.

Usage

## S3 method for class 'HeckmanGe'
summary(object, ...)

Arguments

object

An object of class HeckmanGe, containing the fitted model results.

...

Additional arguments (currently unused).

Details

This method displays the maximum likelihood estimation results for the generalized Heckman sample selection model. It includes separate coefficient tables for:

Model fit statistics (log-likelihood, AIC, BIC, and number of observations) are also reported for interpretation and model assessment.

Value

Prints to the console:

Invisibly returns NULL.

See Also

HeckmanGe

Examples

## Not run: 
data(MEPS2001)
attach(MEPS2001)
selectEq <- dambexp ~ age + female + educ + blhisp + totchr + ins + income
outcomeEq <- lnambx ~ age + female + educ + blhisp + totchr + ins
outcomeS <- ~ educ + income
outcomeC <- ~ blhisp + female
model <- HeckmanGe(selectEq, outcomeEq, outcomeS = outcomeS, outcomeC = outcomeC, data = MEPS2001)
summary(model)

## End(Not run)


Summary of Skew-Normal Heckman Model

Description

Prints a detailed summary of the parameter estimates and model fit statistics for an object of class HeckmanSK.

Usage

## S3 method for class 'HeckmanSK'
summary(object, ...)

Arguments

object

An object of class HeckmanSK, containing the fitted model results.

...

Additional arguments (currently unused).

Details

This method displays the maximum likelihood estimation results for the Heckman sample selection model with Skew-Normal errors. It includes separate coefficient tables for:

Additionally, it reports model fit statistics such as the log-likelihood, AIC, BIC, and the number of observations.

Value

Prints to the console:

Invisibly returns NULL.

See Also

HeckmanSK

Examples

## Not run: 
data(Mroz87)
attach(Mroz87)
selectEq <- lfp ~ huswage + kids5 + mtr + fatheduc + educ + city
outcomeEq <- log(wage) ~ educ + city
model <- HeckmanSK(selectEq, outcomeEq, data = Mroz87, lambda = -1.5)
summary(model)

## End(Not run)


Summary of Heckman-t Model

Description

Prints a detailed summary of the parameter estimates and model fit statistics for an object of class HeckmantS.

Usage

## S3 method for class 'HeckmantS'
summary(object, ...)

Arguments

object

An object of class HeckmantS, containing the fitted model results.

...

Additional arguments (currently unused).

Details

This method displays the maximum likelihood estimation results for the Heckman sample selection model with Student's t-distributed errors. It includes separate coefficient tables for:

Model fit statistics (log-likelihood, AIC, BIC, and number of observations) are also provided for model evaluation.

Value

Prints to the console:

Invisibly returns NULL.

See Also

HeckmantS

Examples

## Not run: 
data(MEPS2001)
attach(MEPS2001)
selectEq <- dambexp ~ age + female + educ + blhisp + totchr + ins + income
outcomeEq <- lnambx ~ age + female + educ + blhisp + totchr + ins
model <- HeckmantS(selectEq, outcomeEq, data = MEPS2001, df = 12)
summary(model)

## End(Not run)


Two-Step Estimation of the Classic Heckman Model

Description

Estimates the parameters of the classical Heckman sample selection model using the two-step procedure.

Usage

twostep(selection, outcome, data = sys.frame(sys.parent()))

Arguments

selection

A formula for the selection equation.

outcome

A formula for the outcome equation.

data

A data frame containing the variables.

Details

The two-step method first estimates a Probit model for the selection equation, then fits an outcome equation that includes the Inverse Mills Ratio (IMR) as an additional regressor to correct for sample selection bias.

Value

A numeric vector containing:

References

There are no references for Rd macro ⁠\insertAllCites⁠ on this help page. For details, see Heckman (1979).

Examples

data(MEPS2001)
attach(MEPS2001)
selectEq <- dambexp ~ age + female + educ + blhisp + totchr + ins + income
outcomeEq <- lnambx ~ age + female + educ + blhisp + totchr + ins
twostep(selectEq, outcomeEq, data = MEPS2001)