我想在R中手动计算一个Heckman选择模型。 我的问题是标准错误是有偏见的。有没有办法手动纠正这些?
来自sampleSelection模型的我的(示例)代码(正确的SE)和手动代码(正确的估计,错误的SE)
require(sampleSelection)
data( Mroz87 )
Mroz87$kids <- ( Mroz87$kids5 + Mroz87$kids618 > 0 )
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)
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)
答案 0 :(得分:0)
myprobit <- probit(lfp ~ age + I(age^2) + faminc + kids + educ - 1, x = TRUE,
iterlim = 30, data=Mroz87)
imrData <- invMillsRatio(myprobit) # same as yours in this particular case
Mroz87$IMR1 <- imrData$IMR1
outeqn1 <- lm(wage ~ -1 + exper + I(exper^2) + educ + city + IMR1,
data=Mroz87, subset=(lfp==1))
主要的是你使用拦截模型而不是无拦截。