Dear Stata community,

I'd like to run an IV regression with interaction terms between the endogenous variable and two other variables to study heterogeneous treatment effects, suppose x1 is the endogenous variable, z is the instrument, x2 and x3 are the two variables to be interacted with x1; x1_x2, x1_x3, z_x2 z_x3 are interactions between x1 and x2, x1 and x3, z and x2, and z and x3, respectively, I'd also like to use ivreghdfe to control for fixed effects. I was wondering if the following code is correct:

ivreghdfe y (x1 x1_x2 x1_x3 = z z_x2 z_x3) x2 x3, a(fe1)

More specifically, I'd like to ask is it right to write the code for instrumenting as (x1 x1_x2 x1_x3 = z z_x2 z_x3)?

Thanks,
Yi