Skip to main content

Heckman Selection Model: What Would the Women Who Did Not Work Have Earned?

The Heckman sample selection model in R, by hand and with sampleSelection, on Mroz’s classic data of 753 married women of whom 428 worked for pay: wages that are seen only for a selected group, the two-step estimator with the inverse Mills ratio, maximum likelihood, testing for selection, why exclusion restrictions decide everything, a simulation with a known truth, predicted wage offers, how it differs from Tobit and two-part models, and APA reporting.

The question: wages that nobody paid

How much more does a woman earn for each year of education? In 1975 a study asked 753 married American women. But only 428 of them worked for pay. For the other 325 there is no wage. Not because the question was left out: there was none to report.

A regression of the wage on education, for the women who worked, describes the women who worked. But the question is usually about all women: what would education be worth to a woman who is at home now? If those who work are a special group, if for example they are the ones who were offered a good wage, then the sample is selected by the very thing we want to explain, and the regression may be wrong.

James Heckman (1979) proposed a model for this situation, with two equations: one that decides who is in the sample, and one for the outcome. It brought him a Nobel Prize, and it is one of the most used, and most misused, models of social science. This page shows what it does, and what it can and cannot repair.

Code
library(ggplot2)
library(sampleSelection)   # selection(): two-step and maximum likelihood

# number formats for the text
f1   <- function(x) formatC(x, format = "f", digits = 1, big.mark = ",")
f2   <- function(x) formatC(x, format = "f", digits = 2, big.mark = ",")
f3   <- function(x) formatC(x, format = "f", digits = 3, big.mark = ",")
# no leading zero
nz <- function(x, d = 2) sub("^(-?)0", "\\1", formatC(x, format = "f", digits = d))
pval <- function(p) if (p < .001) "< .001" else paste("=", nz(p, 3))
num  <- function(x) trimws(format(x, big.mark = ","))
pct  <- function(x, d = 0) paste0(formatC(100 * x, format = "f", digits = d), "%")

1. The data

The data come from the Panel Study of Income Dynamics: married white women, 30 to 60 years old, in 1975. Mroz (1987) used them to show how much the conclusions about women’s work depend on the assumptions, and they have been the standard example ever since.

Code
women <- read.csv("https://vincentarelbundock.github.io/Rdatasets/csv/sampleSelection/Mroz87.csv")
women <- women[, c("lfp", "wage", "educ", "exper", "age", "kids5", "kids618", "nwifeinc")]
women$logwage <- ifelse(women$lfp == 1, log(women$wage), NA) # no wage for those who do not work
str(women)
'data.frame':   753 obs. of  9 variables:
 $ lfp     : int  1 1 1 1 1 1 1 1 1 1 ...
 $ wage    : num  3.35 1.39 4.55 1.1 4.59 ...
 $ educ    : int  12 12 12 12 14 12 16 12 12 12 ...
 $ exper   : int  14 5 15 6 7 33 11 35 24 21 ...
 $ age     : int  32 30 35 34 31 54 37 54 48 39 ...
 $ kids5   : int  1 0 1 0 1 0 0 0 0 0 ...
 $ kids618 : int  0 2 3 3 2 0 2 0 2 2 ...
 $ nwifeinc: num  10.9 19.5 12 6.8 20.1 ...
 $ logwage : num  1.2102 0.3285 1.5141 0.0921 1.5243 ...
Code
works <- women$lfp == 1
c(women = nrow(women), working = sum(works), share = mean(works))
      women     working       share 
753.0000000 428.0000000   0.5683931 

lfp is 1 for a woman who worked for pay in 1975, wage her average hourly earnings in dollars, educ her years of schooling, exper her years of work experience, kids5 and kids618 the number of children under 6 and from 6 to 18, and nwifeinc the income of the family without her earnings, in thousands of dollars. We use the logarithm of the wage, so that a coefficient of 0.10 means about 10% more.


2. Look at the data

Code
groups <- aggregate(
  cbind(educ, exper, age, kids5, kids618, nwifeinc) ~ lfp,
  data = women,
  FUN = mean
)
groups$lfp <- c("not working", "working")
print(cbind(group = groups$lfp, round(groups[, -1], 2)), row.names = FALSE)
       group  educ exper   age kids5 kids618 nwifeinc
 not working 11.80  7.46 43.28  0.37    1.36    21.70
     working 12.66 13.04 41.97  0.14    1.35    18.94
Code
kids_share <- aggregate(lfp ~ kids5, data = women, FUN = mean)
pa <- ggplot(women, aes(factor(kids5), fill = factor(lfp))) +
  geom_bar() +
  scale_fill_manual(
    values = c(`0` = "grey70", `1` = "#2a78d6"),
    labels = c("not working: no wage", "working"),
    name = NULL
  ) +
  labs(title = "Children under 6", x = "number", y = "women") +
  theme_bw() +
  theme(legend.position = "bottom")
pb <- ggplot(subset(women, works), aes(educ, logwage)) +
  geom_point(
    position = position_jitter(width = 0.2, seed = 1),
    alpha = 0.4,
    colour = "grey30",
    size = 1.4
  ) +
  geom_smooth(method = "lm", formula = y ~ x, se = FALSE, colour = "#eb6834") +
  labs(title = "Wages, where they are known", x = "years of education", y = "log hourly wage") +
  theme_bw()
patchwork::wrap_plots(pa, pb)

Plot: 2. Look at the data

The women who worked are a little better educated (12.7 against 11.8 years), have much more experience (13.0 against 7.5 years) and fewer small children. Of the women without a child under 6, 62% worked; of those with one, 39%.


3. The model step by step, with formulas

Step 1: two equations

The outcome equation, for every woman, whether she works or not. It is the wage that she is or would be offered:

\[y_i^* = x_i^\top \beta + \varepsilon_i\]

The selection equation. She works if the advantage of working, \(d_i^*\), is positive:

\[d_i^* = z_i^\top \gamma + u_i, \qquad \text{we see } y_i = y_i^* \text{ only if } d_i^* > 0\]

Step 2: the errors may be correlated

\[\begin{pmatrix} \varepsilon_i \\ u_i \end{pmatrix} \sim N\!\left(0, \begin{pmatrix} \sigma^2 & \rho\sigma \\ \rho\sigma & 1 \end{pmatrix}\right)\]

\(u_i\) is whatever makes her more likely to work than \(z_i\) says: ambition, health, a well-connected aunt. \(\varepsilon_i\) is whatever makes her wage higher than \(x_i\) says: ambition, health, a well-connected aunt. If the two are related (\(\rho \ne 0\)), then those who work have, on average, errors \(\varepsilon\) that are not zero. This is the whole problem. If \(\rho = 0\), selection may depend on everything in \(z\), and OLS on the workers is still fine.

Step 3: the bias of OLS is a missing predictor

For the women who work, the expected error is

\[E(\varepsilon_i \mid u_i > -z_i^\top\gamma) = \rho\sigma\,\lambda_i, \qquad \lambda_i = \frac{\phi(z_i^\top\gamma)}{\Phi(z_i^\top\gamma)}\]

\(\lambda_i\) is the inverse Mills ratio. It is large for women who work although the model says they hardly would (they must have a large \(u\)), and near 0 for those who would work anyway. So

\[E(y_i \mid \text{works}) = x_i^\top\beta + (\rho\sigma)\,\lambda_i\]

OLS leaves out \(\lambda_i\). In Heckman’s words, selection bias is a specification error: an omitted variable.

Step 4: the two-step estimator

  1. Fit a probit regression of working on \(z\), for all the women. Compute \(\hat\lambda_i\).
  2. Fit OLS of the wage on \(x\) and \(\hat\lambda\), for the women who work.

The coefficient of \(\hat\lambda\) estimates \(\rho\sigma\). Its t test is a test of whether there is selection at all. The ordinary standard errors of step 2 are wrong, because \(\hat\lambda\) is estimated and the errors have unequal variances.

Step 5: maximum likelihood

Both equations at once. A woman who does not work contributes \(P(d^* \le 0)\). A woman who works contributes the density of her wage, times the probability of working given that wage:

\[\log L = \sum_{d_i = 0} \log \Phi(-z_i^\top\gamma) + \sum_{d_i = 1} \left[ \log \frac{1}{\sigma}\phi\!\left(\frac{e_i}{\sigma}\right) + \log \Phi\!\left(\frac{z_i^\top\gamma + \rho\, e_i/\sigma}{\sqrt{1 - \rho^2}}\right) \right]\]

with \(e_i = y_i - x_i^\top\beta\).

It is more precise than the two steps if the bivariate normal model is right.

Step 6: exclusion restrictions

If \(x\) and \(z\) contain the same variables, the only thing that tells \(\lambda_i\) from the predictors in \(x\) is its curvature, and over most of its range it is nearly a straight line. The model is then identified by the assumption of normality alone, which is not much. To identify it properly there must be at least one variable in \(z\) that is not in \(x\): something that makes a woman work, but does not change the wage that she would be offered. Here: the income of the rest of the family, her age, and her children. Whether employers really did not care about a woman’s children in 1975 is a question that the model cannot answer.


4. The two steps by hand

Code
# step 1: probit for working
probit <- glm(
  lfp ~ nwifeinc + educ + exper + I(exper^2) + age + kids5 + kids618,
  family = binomial("probit"),
  data = women
)
round(coef(summary(probit)), 3)
            Estimate Std. Error z value Pr(>|z|)
(Intercept)    0.270      0.508   0.532    0.595
nwifeinc      -0.012      0.005  -2.434    0.015
educ           0.131      0.025   5.154    0.000
exper          0.123      0.019   6.575    0.000
I(exper^2)    -0.002      0.001  -3.145    0.002
age           -0.053      0.008  -6.246    0.000
kids5         -0.868      0.118  -7.335    0.000
kids618        0.036      0.044   0.818    0.414
Code
zg <- predict(probit, type = "link")
women$mills <- dnorm(zg) / pnorm(zg)

# step 2: OLS with the inverse Mills ratio, for the women who work
ols   <- lm(logwage ~ educ + exper + I(exper^2), data = women, subset = works)
step2 <- lm(logwage ~ educ + exper + I(exper^2) + mills, data = women, subset = works)
round(cbind(OLS = c(coef(ols), mills = NA), two_step = coef(step2)), 4)
                OLS two_step
(Intercept) -0.5220  -0.5781
educ         0.1075   0.1091
exper        0.0416   0.0439
I(exper^2)  -0.0008  -0.0009
mills            NA   0.0323
Code
ggplot(women, aes(pnorm(zg), mills, colour = factor(lfp))) +
  geom_point(alpha = 0.5, size = 1.4) +
  scale_colour_manual(
    values = c(`0` = "grey60", `1` = "#2a78d6"),
    labels = c("not working", "working"),
    name = NULL
  ) +
  labs(title = "The inverse Mills ratio", x = "probability of working, from the probit", y = "λ") +
  theme_bw() +
  theme(legend.position = "bottom")

Mills chart – 4. The two steps by hand

Small children make work much less likely, age and the family’s other income too; education and experience make it more likely. The coefficient of \(\hat\lambda\) is 0.032: close to zero.


5. The same with the package

Code
two_step <- selection(lfp ~ nwifeinc + educ + exper + I(exper^2) + age + kids5 + kids618,
                      logwage ~ educ + exper + I(exper^2), data = women, method = "2step")
ml       <- selection(lfp ~ nwifeinc + educ + exper + I(exper^2) + age + kids5 + kids618,
                      logwage ~ educ + exper + I(exper^2), data = women, method = "ml")
summary(ml)
--------------------------------------------
Tobit 2 model (sample selection model)
Maximum Likelihood estimation
Newton-Raphson maximisation, 3 iterations
Return code 1: gradient close to zero (gradtol)
Log-Likelihood: -832.8851 
753 observations (325 censored and 428 observed)
14 free parameters (df = 739)
Probit selection equation:
              Estimate Std. Error t value Pr(>|t|)    
(Intercept)  0.2664491  0.5089578   0.524  0.60077    
nwifeinc    -0.0121321  0.0048767  -2.488  0.01307 *  
educ         0.1313414  0.0253823   5.175 2.95e-07 ***
exper        0.1232818  0.0187242   6.584 8.68e-11 ***
I(exper^2)  -0.0018863  0.0006004  -3.142  0.00175 ** 
age         -0.0528287  0.0084792  -6.230 7.81e-10 ***
kids5       -0.8673987  0.1186509  -7.311 6.93e-13 ***
kids618      0.0358724  0.0434753   0.825  0.40957    
Outcome equation:
              Estimate Std. Error t value Pr(>|t|)    
(Intercept) -0.5526963  0.2603785  -2.123   0.0341 *  
educ         0.1083502  0.0148607   7.291 7.93e-13 ***
exper        0.0428368  0.0148785   2.879   0.0041 ** 
I(exper^2)  -0.0008374  0.0004175  -2.006   0.0452 *  
   Error terms:
      Estimate Std. Error t value Pr(>|t|)    
sigma  0.66340    0.02271  29.215   <2e-16 ***
rho    0.02661    0.14708   0.181    0.856    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
--------------------------------------------
Code
Z <- model.matrix(probit); X <- model.matrix(~ educ + exper + I(exper^2), data = women)
y <- ifelse(works, women$logwage, 0)
minus_loglik <- function(par) {
  g <- par[1:ncol(Z)]
  b <- par[ncol(Z) + 1:ncol(X)]
  s <- exp(par[length(par) - 1])
  r <- tanh(par[length(par)])
  a <- drop(Z %*% g)
  e <- (y - drop(X %*% b)) / s
  -sum(ifelse(
    works,
    dnorm(e, log = TRUE) - log(s) + pnorm((a + r * e) / sqrt(1 - r^2), log.p = TRUE),
    pnorm(-a, log.p = TRUE)
  ))
}
hand <- optim(
  c(coef(probit), coef(ols), log(sigma(ols)), 0),
  minus_loglik,
  method = "BFGS",
  control = list(
    maxit = 2000,
    reltol = 1e-12,
    parscale = c(0.5, 0.01, 0.1, 0.1, 0.01, 0.05, 0.3, 0.1, 0.3, 0.1, 0.1, 0.01, 0.1, 0.1)
  )
)
c(
  our_logLik = -hand$value,
  package_logLik = as.numeric(logLik(ml)),
  our_rho = tanh(hand$par[[14]]),
  package_rho = coef(ml)[["rho"]]
)
    our_logLik package_logLik        our_rho    package_rho 
 -832.88508077  -832.88508076     0.02660709     0.02660697 

How to read the output

  • Probit selection equation: who works. Read the coefficients as in any probit: their sign and their ratio, not their size.
  • Outcome equation: the wage offer of all women. One more year of education goes with a wage offer that is 11.4% higher.
  • sigma: the standard deviation of the wage error. rho: the correlation between the two errors, 0.027 with a standard error of 0.147.
Code
row_out <- 9:12                                           # the rows of the outcome equation
compare <- data.frame(
  term = c("Intercept", "Education", "Experience", "Experience²"),
  OLS = coef(ols), SE_OLS = coef(summary(ols))[, 2],
  two_step = coef(two_step)[9:12], SE_2 = sqrt(diag(vcov(two_step)))[9:12],
  ML = coef(ml)[row_out], SE_ML = sqrt(diag(vcov(ml)))[row_out], row.names = NULL)
print(cbind(term = compare$term, round(compare[, -1], 4)), row.names = FALSE)
        term     OLS SE_OLS two_step   SE_2      ML  SE_ML
   Intercept -0.5220 0.1986  -0.5781 0.3050 -0.5527 0.2604
   Education  0.1075 0.0141   0.1091 0.0155  0.1084 0.0149
  Experience  0.0416 0.0132   0.0439 0.0163  0.0428 0.0149
 Experience² -0.0008 0.0004  -0.0009 0.0004 -0.0008 0.0004
Code
lr   <- 2 * (as.numeric(logLik(ml)) - (as.numeric(logLik(probit)) + as.numeric(logLik(ols))))
lr_p <- pchisq(lr, 1, lower.tail = FALSE)
c(LR = lr, p = lr_p)
        LR          p 
0.03216796 0.85765953 

If \(\rho = 0\), the likelihood of the model is that of the probit times that of the OLS regression. So the likelihood-ratio test of selection compares the two: \(\chi^2\)(1) = 0.03, p = .858. We find no sign of selection bias. The return to a year of education is 0.107 with OLS, 0.109 with the two steps and 0.108 with maximum likelihood.

That the correction changes nothing is a common result, and a legitimate one. It does not mean that the workers are like the others: they differ in education, experience and children. It means that what is left, after these, seems not to be related to the wage. Or that our restrictions cannot show it.


6. Everything depends on the exclusion restrictions

What if we had no excluded variables, and the probit contained only what is in the wage equation?

Code
probit0 <- glm(lfp ~ educ + exper + I(exper^2), family = binomial("probit"), data = women)
zg0 <- predict(probit0, type = "link"); women$mills0 <- dnorm(zg0) / pnorm(zg0)
r2_with <- summary(lm(mills ~ educ + exper + I(exper^2), data = women, subset = works))$r.squared
r2_without <- summary(lm(
  mills0 ~ educ + exper + I(exper^2),
  data = women,
  subset = works
))$r.squared
c(R2_of_mills_on_x_with_exclusions = r2_with, without = r2_without)
R2_of_mills_on_x_with_exclusions                          without 
                       0.5392472                        0.9861982 
Code
no_excl <- selection(
  lfp ~ educ + exper + I(exper^2),
  logwage ~ educ + exper + I(exper^2),
  data = women,
  method = "2step"
)
mills_est <- c(with = coef(two_step)[["invMillsRatio"]], without = coef(no_excl)[["invMillsRatio"]])
mills_se <- c(
  with = sqrt(vcov(two_step)["invMillsRatio", "invMillsRatio"]),
  without = sqrt(vcov(no_excl)["invMillsRatio", "invMillsRatio"])
)
# education in the wage equation
educ_est <- c(with = coef(two_step)[[10]], without = coef(no_excl)[[6]])
educ_se   <- c(with = sqrt(vcov(two_step)[10, 10]), without = sqrt(vcov(no_excl)[6, 6]))
rbind(education = educ_est, SE_education = educ_se, mills = mills_est, SE_mills = mills_se)
                   with     without
education    0.10906552  0.09347007
SE_education 0.01552295  0.05141541
mills        0.03226186 -0.27018113
SE_mills     0.13362464  0.94919661

Without exclusions, 98.6% of the variation of \(\hat\lambda\) is already in the predictors of the wage (with them, 54%). The inverse Mills ratio is nearly a copy of \(x\). Its coefficient is estimated as -0.27 with a standard error of 0.95, and the standard error of the education coefficient grows from 0.016 to 0.051. The correction is then worse than the disease.

A known truth

A simulation with the real predictors shows both sides. The true return to education is 0.10. We set the correlation \(\rho\) of the errors to 0, 0.5 and 0.8, and estimate with OLS, with the two steps, and with the two steps without exclusion restrictions (the data are generated with them):

Code
set.seed(41)
beta  <- c(-0.5, 0.10, 0.04, -0.0008); s0 <- 0.66; gamma0 <- coef(probit)
reps  <- 500
heck  <- function(yy, d, Zm) {                                         # two-step, by hand, fast
  p  <- suppressWarnings(glm.fit(Zm, d, family = binomial("probit")))
  a  <- drop(Zm %*% p$coefficients); m <- dnorm(a) / pnorm(a)
  unname(lm.fit(cbind(X[d == 1, ], m[d == 1]), yy[d == 1])$coefficients[2])
}
one <- function(rho) {
  u <- rnorm(nrow(X))
  e <- s0 * (rho * u + sqrt(1 - rho^2) * rnorm(nrow(X)))
  d <- as.integer(drop(Z %*% gamma0) + u > 0)
  yy <- drop(X %*% beta) + e
  c(
    OLS = unname(lm.fit(X[d == 1, ], yy[d == 1])$coefficients[2]),
    two_step = heck(yy, d, Z),
    no_exclusions = heck(yy, d, X)
  )
}
sims <- do.call(
  rbind,
  lapply(c(0, 0.5, 0.8), function(rho) {
    r <- t(replicate(reps, one(rho)))
    data.frame(
      rho,
      method = colnames(r),
      mean = colMeans(r),
      SD = apply(r, 2, sd),
      RMSE = sqrt(colMeans((r - 0.10)^2)),
      row.names = NULL
    )
  })
)
print(
  transform(sims, mean = round(mean, 4), SD = round(SD, 4), RMSE = round(RMSE, 4)),
  row.names = FALSE
)
 rho        method   mean     SD   RMSE
 0.0           OLS 0.1008 0.0133 0.0134
 0.0      two_step 0.1004 0.0145 0.0145
 0.0 no_exclusions 0.1019 0.0491 0.0491
 0.5           OLS 0.0839 0.0133 0.0209
 0.5      two_step 0.0989 0.0147 0.0147
 0.5 no_exclusions 0.0958 0.0483 0.0485
 0.8           OLS 0.0753 0.0130 0.0279
 0.8      two_step 0.0993 0.0148 0.0148
 0.8 no_exclusions 0.0955 0.0446 0.0448
Code
get <- function(rho, m, col) sims[sims$rho == rho & sims$method == m, col]
Code
sims$label <- factor(
  sims$method,
  levels = c("OLS", "two_step", "no_exclusions"),
  labels = c("OLS", "two-step, with exclusion restrictions", "two-step, without")
)
ggplot(sims, aes(mean, factor(rho), colour = label)) +
  geom_vline(xintercept = 0.10, linetype = "dashed") +
  geom_pointrange(
    aes(xmin = mean - 2 * SD, xmax = mean + 2 * SD),
    position = position_dodge(width = 0.6),
    linewidth = 0.9
  ) +
  scale_colour_manual(values = c("#eb6834", "#2a78d6", "grey50"), name = NULL) +
  labs(
    title = "500 simulated studies: the return to education (truth: 0.10)",
    subtitle = "Points: mean of the estimates. Lines: plus and minus two standard deviations",
    x = "estimate",
    y = "correlation of the errors, ρ"
  ) +
  theme_bw() +
  theme(legend.position = "bottom", legend.direction = "vertical")

Simulation chart – A known truth

  • With \(\rho\) = 0.8, OLS gives 0.075 on average, below the truth of 0.10: the bias is real. The two steps give 0.099.
  • With \(\rho\) = 0 OLS is right and more precise: its typical error is 0.013 against 0.015 for the two steps. The correction has a price.
  • Without exclusion restrictions the two steps are right on average, but the spread is 3.0 times as large as with them. A single study may land anywhere. With \(\rho\) = 0.8 their typical error, 0.045, is larger than that of the biased OLS, 0.028.

7. What would the others have earned?

The outcome equation gives a wage offer to every woman. For the women at home there are two predictions: the unconditional one, \(x^\top\beta\), for any woman with such education and experience, and the one given that she does not work, which uses the selection term with the opposite sign:

\[E(y_i^* \mid \text{does not work}) = x_i^\top\beta - \rho\sigma\,\frac{\phi(z_i^\top\gamma)}{1 - \Phi(z_i^\top\gamma)}\]

Code
xb      <- drop(X %*% coef(ml)[9:12])
rs      <- coef(ml)[["rho"]] * coef(ml)[["sigma"]]
a       <- drop(Z %*% coef(ml)[1:8])
offer   <- ifelse(works, xb + rs * dnorm(a) / pnorm(a), xb - rs * dnorm(a) / pnorm(-a))
ols_hat <- drop(X %*% coef(ols))
wages <- data.frame(group = c("working", "not working"),
                    observed      = c(mean(women$logwage[works]), NA),
                    unconditional = c(mean(xb[works]), mean(xb[!works])),
                    conditional   = c(mean(offer[works]), mean(offer[!works])),
                    OLS           = c(mean(ols_hat[works]), mean(ols_hat[!works])))
print(cbind(group = wages$group, round(wages[, -1], 3)), row.names = FALSE)
       group observed unconditional conditional   OLS
     working     1.19         1.181       1.190 1.190
 not working       NA         0.959       0.946 0.972
Code
gap <- 1 - exp(mean(offer[!works]) - mean(offer[works]))
gap
[1] 0.2164733

On this model, the women who did not work would have been offered wages 22% lower than those of the women who worked, nearly all of it because of less experience and education. With \(\rho\) so close to zero, the selection term adds almost nothing, and OLS says the same. The log wage is predicted; for dollars one also needs \(e^{\sigma^2/2}\).


8. Things to keep in mind

  • Find an exclusion restriction before you run the model, and defend it. Without one, do not use the Heckman correction (Puhani, 2000; Bushway et al., 2007).
  • The predictors of the outcome belong in the selection equation too. Leaving one out biases everything.
  • It is not a cure for every missing outcome. If the outcome is missing for reasons that are in your predictors, OLS or multiple imputation is better. Heckman’s model is for missingness that depends on the unseen part of the outcome.
  • Normality carries a lot of weight. There are versions with other distributions, and semiparametric ones that need stronger exclusion restrictions.
  • A non-significant \(\hat\lambda\) is not proof that there is no selection. With weak exclusions the test has little power.
  • The two steps need special standard errors. The package has them; OLS with a column \(\hat\lambda\) has not.
  • Bounds. Without any model one can still say something. If the missing outcomes lie within known limits, the answer lies within limits (Manski, 1989). They are often wide, and that is the honest measure of what the data say.
Situation Model
Values pile up at a limit because they cannot be recorded beyond it Tobit
Cases beyond a limit of the outcome are missing Truncated regression
Outcome seen only for a group selected by another decision, related to the outcome’s error; interest in everybody Heckman
A real zero for some (no purchase), and an amount for the others; interest in the observed outcome Two-part (hurdle) model

9. Reporting the results in APA style

A report (APA 7th edition) needs the two equations, the excluded variables and the argument for them, the estimator, \(\rho\) with its test, and the uncorrected estimates for comparison. The numbers come from the R objects:

Code
sm  <- coef(summary(ml))
est <- sm[, 1]; se <- sm[, 2]
fmt <- function(v, d) mapply(function(x, k) formatC(x, format = "f", digits = k), v, d)
apa_table <- data.frame(
  Predictor = c(
    "Intercept", "Education (years)", "Experience (years)", "Experience squared",
    "Non-wife income ($1,000)", "Age (years)", "Children under 6", "Children 6–18"
  ),
  sel = paste0(
    fmt(est[c(1, 3, 4, 5, 2, 6, 7, 8)], c(3, 3, 3, 4, 3, 3, 3, 3)),
    " (",
    fmt(se[c(1, 3, 4, 5, 2, 6, 7, 8)], c(3, 3, 3, 4, 3, 3, 3, 3)),
    ")"
  ),
  out = c(
    paste0(fmt(est[9:12], c(3, 3, 3, 4)), " (", fmt(se[9:12], c(3, 3, 3, 4)), ")"),
    rep("—", 4)
  ),
  ols = c(
    paste0(fmt(coef(ols), c(3, 3, 3, 4)), " (", fmt(coef(summary(ols))[, 2], c(3, 3, 3, 4)), ")"),
    rep("—", 4)
  )
)

Method (data analysis):

Wages were observed only for the 428 of 753 married women who worked for pay in 1975 (Mroz, 1987). We estimated the determinants of the log hourly wage with Heckman’s (1979) sample selection model by maximum likelihood. The wage equation contained education, experience and its square; the selection equation contained these and the income of the other family members, age, and the numbers of children under 6 and between 6 and 18, which we assumed to affect the decision to work but not the wage offered. Selection was tested with a likelihood-ratio test of ρ = 0, and the results were compared with ordinary least squares on the working women and with the two-step estimator. Analyses were conducted in R (Version 4.6.2; R Core Team, 2026) with the package sampleSelection (Toomet & Henningsen, 2008).

Results:

Women were less likely to work if they had children under 6, b = -0.87, SE = 0.12, z = -7.31, p < .001, were older, or had a higher family income from others (Table 1). Each year of education went with a wage offer that was 11.4% higher, b = 0.108, SE = 0.015, 95% CI [0.079, 0.137]. The errors of the two equations were not significantly correlated, ρ = .03, χ²(1) = 0.03, p = .858, and the coefficient of education was nearly the same as without the correction (0.107). We therefore find no evidence of selection bias under the assumed exclusion restrictions.

Table 1

Sample Selection Model of Women’s Wages

Predictor Working (probit) Log wage (ML) Log wage (OLS, working women)
Intercept 0.266 (0.509) -0.553 (0.260) -0.522 (0.199)
Education (years) 0.131 (0.025) 0.108 (0.015) 0.107 (0.014)
Experience (years) 0.123 (0.019) 0.043 (0.015) 0.042 (0.013)
Experience squared -0.0019 (0.0006) -0.0008 (0.0004) -0.0008 (0.0004)
Non-wife income ($1,000) -0.012 (0.005) — —
Age (years) -0.053 (0.008) — —
Children under 6 -0.867 (0.119) — —
Children 6–18 0.036 (0.043) — —

Note. Estimates with standard errors in parentheses. N = 753, of whom 428 worked. ρ = .03 (SE = .15), σ = 0.66.

Points to remember:

  • Name the excluded variables and argue for them.
  • Report the selection equation as well.
  • Show the uncorrected estimates.
  • Report \(\rho\) with its uncertainty, and say what the test can and cannot show.
  • Say to whom the coefficients apply: the whole population, not those who were seen.

10. Summary

When The outcome is seen only for a group selected by a decision that is related to the outcome’s error
The model A probit for selection and a regression for the outcome, with correlated normal errors
The bias A missing predictor: \(\rho\sigma\lambda\), with \(\lambda\) the inverse Mills ratio
How (R) sampleSelection::selection(d ~ z1 + z2 + x, y ~ x, data, method = "ml") or "2step"
Needs At least one variable that moves selection but not the outcome
Test \(\rho = 0\): likelihood ratio, or the t test of \(\hat\lambda\)
If \(\rho = 0\) OLS on those who are seen is right, and more precise
Without exclusions Identified by normality alone: do not
Related pages Truncated regression, Tobit, missing data

References

Bushway, S., Johnson, B. D., & Slocum, L. A. (2007). Is the magic still there? The use of the Heckman two-step correction for selection bias in criminology. Journal of Quantitative Criminology, 23(2), 151–178. https://doi.org/10.1007/s10940-007-9024-4

Heckman, J. J. (1979). Sample selection bias as a specification error. Econometrica, 47(1), 153–161. https://doi.org/10.2307/1912352

Manski, C. F. (1989). Anatomy of the selection problem. The Journal of Human Resources, 24(3), 343–360. https://doi.org/10.2307/145818

Mroz, T. A. (1987). The sensitivity of an empirical model of married women’s hours of work to economic and statistical assumptions. Econometrica, 55(4), 765–799. https://doi.org/10.2307/1911029

Puhani, P. A. (2000). The Heckman correction for sample selection and its critique. Journal of Economic Surveys, 14(1), 53–68. https://doi.org/10.1111/1467-6419.00104

Toomet, O., & Henningsen, A. (2008). Sample selection models in R: Package sampleSelection. Journal of Statistical Software, 27(7), 1–23. https://doi.org/10.18637/jss.v027.i07