# Does 2SLS Endogenous Interactions Use Fitted Values?

I'll try to keep this short. I am using the R fixest package. I have the following regression that I've simplified for the example:

feols(y ~ x1 + i(x1, x2, "reference") | x2 ~ instrument, data = myData)

Basically, I am running a 2SLS, where I am using "instrument" as an instrument for one of my variables, x2, but I also want to interact the fitted values for x2 against another variable, x1. When I run this code, the output calls x2 "fit_x2" like normal, but it only says "x2" for the interaction terms. I'm unsure if the function is actually using the fitted values for x2 from the 1st stage for the interaction terms, and I wish to have this clarified. So, if anyone has experience with this package, your help would be greatly appreciated.

Econometrically, I'm 90% sure it is OK to have interactions with an instrumented variable, so I believe I am seeking out sane results. But, if I am mistaken, please excuse me, and just politely let me know! Perhaps I am supposed to instrument my interactions as well, explicitly with the instrumental variable.

Thanks!

• To answer your secondary question, quoting Balli & Sørensen: "In the case where, say, $X_2$ is endogenous, $X_1$ is exogenous, and $Z$ is a valid instrument for $X_2$, $X_{1}Z$ will be a valid instrument for $X_{1}X_{2}$." Jun 2, 2023 at 19:48
• Ah, thank you, that does make sense. I'm still uncertain, though - do I really need to find fitted values for $X_1X_2$? Or, if I have the fitted values for $X_2$ already, can I not just use those for the interaction term in my second-stage regression and be fine? In my scenario, $X_1$ is a categorical variable, and $X_2$ is numeric, so I'm unsure if that means that I'd have to get fitted values for each category, if that makes sense. Jun 7, 2023 at 3:46
• I've created a separate question relating to your comment, as I did some of my own testing and got inconclusive results. No pressure to answer, just wanted to put it out there. Jun 7, 2023 at 6:11

I did my own testing, and the feols() function does appear to only replace the stand-alone instance of the endogenous variable $$x_2$$ with the first-stage fitted values, and continues to use the regular, non-fitted values of $$x_2$$ in the interaction term. This is what the output of the regression shows in the console, so there is no bug or mistake.
In terms of the econometrics, I'm actually unsure whether I was setting up my model correctly (see my comment). However, considering my primary question was just about how the feols() function works, I'd consider this answered.