I would like to replicate a model I am using in eregress (Stata 15 and up) with ivreg2 (Baum et al user-written command SSC).
I am using Stata 16.
This is all just for robustness checks of the eregress model, so I wanted to run the ivreg2 for the post-estimation diagnostics (which are fantastic, by the way). However, I would be happy with a solution in which the results of eregress = ivregress.
The model I *actually* am using in eregress is this:
Code:
eregress outcome_rate i.category## i.moderator controldummy growthrate , endog (moderator= c.instrument i.category controldummy growthrate, nomain) vce(robust)
In the simulated data below, there are 3 possible categories and I don't have enough instruments. In the real data, things are worse because the I have 5 possible values for the categorical variable and I would need around 10 instruments.
As a workaround, I created a brute force interaction so that I wouldn't need 8 extra instruments (yes, I know that is not how one should handle interactions, but I ask that you please keep playing along here).
THE PROBLEM is that I can't get the two commands to give the same results with the interaction.
Starting with a plain model. these give equivalent results (coefficients are nearly identical):
Code:
ivreg2 outcome_rate i.category ( moderator = c.instrument ) controldummy growthrate , robust
Code:
eregress outcome_rate i.category i.moderator controldummy growthrate , endog (moderator= c.instrument i.category controldummy growthrate, nomain) vce(robust)
Code:
gen interaction= category*moderator
Code:
ivreg2 outcome_rate i.category ( moderator interaction = c.instrument c.instrument#interaction ) controldummy growthrate , robust
But in eregress I either have to include the whole interaction or leave it out, but what I want to do is put just the endogenous part of the interaction into the endog() part of the model.
Neither of these next models are equivalent to the ivreg2:
Code:
eregress outcome_rate i.category moderator interaction controldummy growthrate , endog (moderator= c.instrument i.category interaction controldummy growthrate, nomain) vce(robust)
Code:
eregress outcome_rate i.category moderator interaction controldummy growthrate, endog (moderator= c.instrument i.category controldummy growthrate, nomain) vce(robust)
Code:
eregress outcome_rate i.category moderator interaction controldummy growthrate , endog (moderator = c.instrument i.category interaction controldummy growthrate, nomain) endog (interaction = c.instrument i.category controldummy growthrate, nomain)vce(robust)
Help! I'm hoping the Stata-listers might see something I have not---either to make ivreg2=eregress OR get around the lack of instruments when you have an endogenous variable that must be interacted with a 5-level category.
Thanks so much!
-Renee
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float outcome_rate byte(category moderator controldummy) float(growthrate instrument) .0512572 1 0 0 -1.158599 1.200202 1.4415318 2 1 1 -1.6130273 .8802252 .4398367 2 0 0 -1.5614135 1.1793866 2.0684404 1 0 1 -1.1937082 .9026076 .020747656 2 0 0 -.8504853 .8710138 .04264894 2 0 0 -1.1334147 .8710138 2.1645558 1 0 0 -.7279454 .8710138 -1.0435052 1 1 0 -.9729756 1.18916 1.2788826 2 0 0 .25533304 1.2002015 .4057586 2 0 0 -1.416769 .9069632 1.1645558 1 0 0 -.7279454 .8710138 1.0435052 1 1 0 -.9729756 1.18916 .2788826 1 1 1 .25533304 1.2002015 -.4057586 2 1 1 -1.416769 .9069632 .0512572 3 1 0 -1.158599 1.200202 1.4415318 3 1 1 -1.6130273 .8802252 .4398367 3 0 1 -1.5614135 1.1793866 2.0684404 3 1 1 -1.1937082 .9026076 .020747656 3 1 0 -.8504853 .8710138 .04264894 3 0 0 -1.1334147 .8710138 end
0 Response to replicating an instrumented model in eregress and ivreg2 (or ivregress)
Post a Comment