

set scheme s1mono
clear
set obs 10000
set seed 1
gen a = rnormal()
gen b = rnormal()
gen e = 2*rnormal()
gen y = 2 + 3*a + 4*b + 5*a*b + e
summarize y a b
estimates clear
regress y c.a##c.b
estimates store M1
regress y c.a c.b
estimates store M2
regress y c.b c.a#c.b
estimates store M3
regress y c.a c.a#c.b
estimates store M4
regress y c.a#c.b
estimates store M5
estimates restore M1
margins, at(a=(-1 0 1) b=(-1 0 1))
marginsplot, name(M1, replace) noci ///
title("M1: Main terms and interaction") legend(col(1))
estimates restore M2
margins, at(a=(-1 0 1) b=(-1 0 1))
marginsplot, name(M2, replace) noci ///
title("M2: Main terms, no interaction") legend(off)
estimates restore M3
margins, at(a=(-1 0 1) b=(-1 0 1))
marginsplot, name(M3, replace) noci ///
title("M3: Interaction, one main term missing") legend(off)
estimates restore M4
margins, at(a=(-1 0 1) b=(-1 0 1))
marginsplot, name(M4, replace) noci ///
title("M4: Interaction, other main term missing") legend(off)
estimates restore M5
margins, at(a=(-1 0 1) b=(-1 0 1))
marginsplot, name(M5, replace) noci ///
title("M5: Interaction term, both main terms missing") legend(off)
grc1leg M1 M2 M3 M4 M5, col(2) ysize(11) xsize(8) ring(0) pos(5) ycommon
estimates table M1 M2 M3 M4 M5, b(%9.2f) stat(F r2_a)