Dear All,

In my research, for example, trunk is the endogenous independent variable of interest and headroom is the instrument variable for trunk. Both headroom and trunk is continuous variable.

Let’s assume we are interested in the parameter estimates of the following recursive model:
Code:
sysuse auto,clear
ivreg2 price displacement (trunk=headroom), robust
My question is: I want study the effect of trunk on price at different level of trunk. How should I instrument for the bin of trunk?
In OLS, I can create 3 bins of trunk according to the value of trunk is high/middle/low, in stata:

Code:
sysuse auto.dta, clear
sum trunk, detail
gen trunk_high=(trunk>=`r(p75)')
gen trunk_mid=(trunk>`r(p25)' & trunk<`r(p75)')
gen trunk_low=(trunk<=`r(p25)')
reg price trunk_high trunk_mid trunk_low displacement, robust
​​
How can I instrument for trunk_high trunk_mid trunk_low according to the predicted value in first-stage.
Is the following code correct?

Code:
sysuse auto.dta, clear

sum trunk, detail
gen trunk_high=(trunk>=`r(p75)')
gen trunk_mid=(trunk>`r(p25)' & trunk<`r(p75)')
gen trunk_low=(trunk<=`r(p25)')


reg trunk displacement
predict trunk_hat

sum trunk_hat, detail
gen trunk_hat_high=(trunk_hat>=`r(p75)')
gen trunk_hat_mid=(trunk_hat>`r(p25)' & trunk_hat<`r(p75)')
gen trunk_hat_low=(trunk_hat<=`r(p25)')

ivreg2 price displacement (trunk_high trunk_mid trunk_low = trunk_hat_high trunk_hat_mid trunk_hat_low), robust

​​