1
votes

I am running a two-stage least squares (2SLS) regression in Stata (panel data). I have one exogenous variable (x1), one endogenous variable (x2), and one instrument for x2 (z). I interested in the effect of x2 on y, and in particular in the effect of the interaction x1*x2 on y.

What I wrote is:

xtivreg2 2sls y x1 (x2 c.x2#i.x1 = z i.z#i.x1), fe

I always get error message "operator invalid" for c.x2#i.x1.

Could anyone help here?

1

1 Answers

1
votes

Don't use factor variable notation and define them by hand:

use http://fmwww.bc.edu/ec-p/data/macro/abdata.dta, clear
tsset id year
gen nk = n*k
gen l2nk = l2.n*k
xtivreg2 ys k (n nk = l2.n l2nk), fe

However, this may be a bad idea for forbidden regression reasons. Take a look at this Statalist thread, especially Mark's response.