Hi all, I am trying to correct for a model with a potential endogenous binary explanatory variable by using the control function approach. Since my endogenous variable is binary, my first stage is a probit, and the second stage is poisson or negative binominal (with the estimated errors from the first-stage as one of the explanatory variables). To implement control function approach, I need to calculate generalized residuals for the second stage. Currnetly, I made the below stata code:
In Stata:
probit y x
predict xb, xb
grhat = cond(y == 1, normalden(xb)/normal(xb), -normalden(xb)/(1-normal(xb)))
Am I using correct codes? Thank you so much for your help in advance
Best
Comment