sergiocorreia / ivreghdfe

Run IV/2SLS with many levels of fixed effects (i.e. ivreg2+reghdfe)
MIT License
77 stars 27 forks source link

Use ivreghdfe followed by predictnl #42

Open nicolaslonguetmarx opened 2 years ago

nicolaslonguetmarx commented 2 years ago

Hello Sergio,

I am using ivreghdfe 1.1.1 with ivreg2 4.1.11 on Stata 17 (Windows 10). I want to estimate the predicted probability after having run an IV regression of the log odds ratio on covariates and fixed effects. Here is what I run:

ivreghdfe log_odds_ratio (X = Z ) C [pw=weights], absorb(year county_fe) cluster(state) predictnl pred_prob=exp(predict(xbd))/(1+exp(predict(xbd))) , se(pred_prob_se) which returns: you must add the resid option to reghdfe before running this prediction predict(xbd) invalid r(198);

then adding the resid option returns: ivreghdfe log_odds_ratio (X = Z ) C [pw=weights], absorb(year county_fe) cluster(state) resid predictnl pred_prob=exp(predict(xbd))/(1+exp(predict(xbd))) , se(pred_prob_se)

expression is a function of possibly stochastic quantities other than e(b) r(498);

(Note: using margins instead of predictnl returns the exact same errors).

Any suggestions on how to estimate non-linear predictions with many fixed?

Thanks a lot!