I’ve got this IV specification that I would like to plot to have the marginal effect of x1 on y as a function of x2:
ivreg2 y= (x1 x1#x2 = z1 z1#x2), endog(x1 x1#x2)
with x1
and x2
continuous and z1
binary.
I’ve tried to do this, but the confidence intervals seem linear. Is this normal?
generate baseline = 1 if e(sample)
matrix b1 = e(b1)
matrix b2 = e(b2)
scalar b1 = b[1,1]
scalar b2 = b[1,2]
scalar varb1 = V[1,1]
scalar varb2 = V[2,2]
scalar covb1b2 = V[1,2]
generate MVL = x2
gen conbl = b1 + b2 * MVL
gen consl = sqrt(varb1 + varb2 * (MVL^2) + 2 * covb1b2 * MVL)
gen al = 1.65 * consl
gen upperl = conbl + al
gen lowerl = conbl - al
graph twoway line conbl MVL, lpattern(solid) clwidth(medium) clcolor(black) || line upperl MVL, clpattern(longdash) clwidth(thin) clcolor(gs8) sort || line lowerl MVL, clpattern(longdash) clwidth(thin) clcolor(gs8) sort ||, yscale(noline) xscale(noline) yline(0, lcolor(black)) xtitle("x2", size(3)) xsca(titlegap(2)) ysca(titlegap(2)) ytitle("Marginal Effect of x1", size(3)) scheme(s2mono) graphregion(fcolor(white)) legend(off)
Thank you !