sergiocorreia / ivreghdfe

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

`margins` postestimation command not supported #11

Open sergiocorreia opened 5 years ago

sergiocorreia commented 5 years ago

Code:

sysuse auto, clear
reghdfe price weight i.foreign (length=gear), absorb(turn trunk) old
margins i.foreign

Underlying issue: ivreg2 does not support margins if used with partial()

ivreg2 price weight i.foreign, partial(weight)
margins i.foreign

Possible soln: study when is it valid to use margins+partial

meadover commented 5 years ago

In a comment on the -reghdfe- branch, I've just submitted a test script which demonstrates that -margins- works fine after -reghdfe- when there are no instrumental variables.

This test script testivreghdfe.zip shows that, after estimation of a fixed-effects IV model with -reghdfe,old-, -margins- does work with the -contrasts- option or with the -dydx- option. However, -margins does not work in the absence of those options.

The test script compares the performance of -reghdfe, old- to the performance of Stata's official --ivregress- and -xtivreg,fe- commands. the comparison suggests that -ivreghdfe- could be compatible with -margins- if its treatment of the constant term were more similar to the treatment accorded the constant by Stata's -xtivreg,fe- command.