Hi

I am running a regression with a binary endogenous variable in the first stage. I am trying to use the control function approach by Professor Jeff Wooldridge Here are the codes I am trying to use:

xtprobit y2 iv1 iv2 x i.year
predict xb, xb
gen gr=cond(y2==1, normalden(xb)/normal(xb), -normalden(xb)/(1-normal(xb)))
xtreg y1 y2 gr x i.year, fe

where y2 is a dummy variable and endogenous, gr is the generalized residuals. I used the method posted by Scott Merryman Scott Merryman in 2003 (https://www.stata.com/statalist/arch.../msg00650.html). I find a few people were asking whether this is a correct method to compute the residuals, however there was no confirmed answers about this. And is the above method also correct for panel data?

Could Professor Wooldridge or others help please?

Thank you very much indeed!

Jing