0

Any idea on how to run the Heckman correction on a complex survey data in R?

I've tried doing it manually, but no success so far...

For the first stage I ran the svyglm() function from the survey package which works well and I was able to estimate the probit model . However, for the second stage I'm having trouble including the predicted inverse Mills ratio (λ) in the svyglm() function.

Vinícius Félix
  • 8,448
  • 6
  • 16
  • 32
RCM
  • 3
  • 1
  • Please can you show the specific piece of code that's not working. – Jean-Paul Sep 28 '21 at 15:29
  • If you mean the Heckman sample selection model, the [`sampleSelection` package](https://cran.r-project.org/web/packages/sampleSelection/vignettes/selection.pdf) might be helpful. – eipi10 Sep 28 '21 at 16:00
  • [See here](https://stackoverflow.com/q/5963269/5325862) on making a reproducible example that is easier for folks to help with, including data and code – camille Sep 28 '21 at 16:33

1 Answers1

0

You can try something similar:

# my probit model - First stage

pb =  svyglm(sel ~  x + y + z,   # generic variables
                       design   = my_design,
                       family = binomial(link = 'probit'))
# update my design

my_design <- update( my_design , mills = dnorm(predict(pb))/pnorm(predict(pb)))

# Heckman model - Second stage

heck = svyglm(log_wage ~ k + l + x 
                          mills,
                        design = my_design,
                        weights =  V)
Alien
  • 116
  • 8