Stata: Interaction effects between one endogenous regressor and two exogenous regressors

I am new to using xtivreg2 - and have a question. Sorry if this has been addressed before.

Here goes.

My question is on 2SLS regression with panel data. I am interested in estimating an interaction effects model with one endogenous regressor (X1) and two endogenous regressors X2 and X3

Y = X1 + X1* X2 + X1* X3 + controls1

X1 is endogenous X2 and X3 are exogenous Controls1- set of controls to explain Y

And X1= Z+ controls2 Controls2 – set of controls to explain X1

Right now I am doing it 2SLS by hand, by predicting X1hat and sticking it in the equation for Y. I am concerned that this may not be the right way to do it.

Based on some material I have seen on Stata forums, I understand that I have to instrument X1*X2 by Z*X2.. and in essence estimate this model as a multiple endogenous regressor model.

Rajashri Srinivasan

• Welcome to CV. Please make your question explicit. While it may be obvious to you what you are asking, this is not necessarily the case for your potential respondents. Aug 2 '16 at 19:47
• To clarify, I am currently using estimates of the endogenous regressor X1 and computing the interaction terms by hand to create the interaction terms for my equation 1 for Y. Aug 2 '16 at 19:55
• That's great. What's your question? Aug 2 '16 at 20:11
• My question is can I use the predicted X1hat from the first stage and do the regression for Y and then obtain corrected standard errors using bootstrapping. Thanks Aug 2 '16 at 20:22
• @RajiSrinivasan You probably meant to write "one endogenous regressor (X1) and two exogenous regressors X2 and X3". Aug 2 '16 at 20:52

This is a common mistake.

Here is the right way to do it, all in one step (towards the end). I also show your method with my first stage to keep it apples to apples, as well as OLS. Note that I also added own effects for X2 and X3, since that is generally good practice.

set more off
webuse nlswork, clear
gen tenureXage = c.tenure#c.age
gen tenureXhours = c.tenure#c.hours

/* OLS */
xtreg ln_w i.not_smsa c.tenure##(c.age c.hours), fe
margins, dydx(tenure) at(age=30 hour=40)

/* Your Method With My First Stage */
xtreg tenure i.not_smsa i.union##(c.age c.hours), fe
predict that, xbu
xtreg ln_w i.not_smsa c.that##(c.age c.hours), fe
margins, dydx(that) at(age=30 hour=40)

/* My Method */
xtivreg ln_w i.not_smsa c.age c.hours (tenure tenureXage tenureXhours = i.union##(c.age c.hours)), fe first
nlcom ME: _b[tenure] + _b[tenureXage]*30 + _b[tenureXhours]*40

The last line gives you the marginal effect of endogenous tenure for a thirty-year-old who works 40 hours a week. Note how different it is from your approach and from OLS.

• Thanks s much Dimitriy, I will try this and may come back to you if I have any questions. Aug 4 '16 at 13:53
• @RajiSrinivasan Did this work? Aug 9 '16 at 10:19
• Hi Dimitry, Yes it did...In fact, I am just running it. Thank you very much! Aug 10 '16 at 14:11
• @RajiSrinivasan No need to thank me. You can select my answer as the one if it helps. Aug 10 '16 at 14:15
• OK, so I am new to this forum...can you tell me how to select your answer as the correct one! Thanks, Raji Aug 10 '16 at 14:55