Dear Statalist,

I want to calculate treatment heterogeneity in a two-stage-least-square (TSLS) setting. I have a continuous dependent variable y, a potentially endogenous predictor x (continuous), and an instrument z (continuous) that provides quasi-random variation in x.

I use z to obtain a TSLS estimate (the local average treatment effect) for x. Now I want to calculate heterogeneous treatment effects for categories of w. In the specific case, w are three age categories, and I want to obtain TSLS estimates for the three age groups.

(How) can I do this using the ivregress command?

I considered estimating the effects separately in three different equations, i.e.

Code:
ivregress 2sls y (x = z) if w==1
ivregress 2sls y (x = z) if w==2
ivregress 2sls y (x = z) if w==3
But is there also a way to specify this in a single model, for example

Code:
ivregress 2sls y (c.x#i.w = c.z#i.w)
?

Your help is much appreciated.

Max