I would like to calculate a Heckman selection model manually in R. My problem is that the standard errors are biased. Is there a way to correct these manually as well?
Below my (sample) code from the sampleSelection model (correct SEs), and the manual code (correct Estimates, wrong SEs)
require(sampleSelection)
data( Mroz87 )
Mroz87$kids <- ( Mroz87$kids5 + Mroz87$kids618 > 0 )
Using sampleSelection
heckman <- selection(selection = lfp ~ age + I(age^2) + faminc + kids + educ, outcome = wage ~ exper + I(exper^2) + educ + city,
data = Mroz87, method = "2step")
summary(heckman)
Manually
seleqn1 <- glm(lfp ~ age + I(age^2) + faminc + kids + educ, family=binomial(link="probit"), data=Mroz87)
summary(seleqn1)
# Calculate inverse Mills ratio by hand ##
Mroz87$IMR <- dnorm(seleqn1$linear.predictors)/pnorm(seleqn1$linear.predictors)
# Outcome equation correcting for selection ## ==> correct estimates, wrong SEs
outeqn1 <- lm(wage ~ exper + I(exper^2) + educ + city + IMR, data=Mroz87, subset=(lfp==1))
summary(outeqn1)