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 X1X2 by ZX2.. and in essence estimate this model as a multiple endogenous regressor model.

  • $\begingroup$ 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. $\endgroup$ Aug 2, 2016 at 19:47
  • $\begingroup$ 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. $\endgroup$ Aug 2, 2016 at 19:55
  • $\begingroup$ That's great. What's your question? $\endgroup$ Aug 2, 2016 at 20:11
  • $\begingroup$ 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 $\endgroup$ Aug 2, 2016 at 20:22
  • $\begingroup$ @RajiSrinivasan You probably meant to write "one endogenous regressor (X1) and two exogenous regressors X2 and X3". $\endgroup$
    – dimitriy
    Aug 2, 2016 at 20:52

1 Answer 1


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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.