Hi Statalisters,
I'm using Stata 14.1, and have a question about the marginsplot. I'm trying to plot the interaction effect between x1 (continuous variable) and x2 (categorical) on the outcome (health). The basic idea is to see the moderating effect of x1 on the association between x2 and health. x2 consist of three categories (0 1 2). However, when I plotted the figure through marginsplot, all values is vertically in the same category of x2 variable, and I cannot differentiate the confident interval, since all CIs are overlapping one another.
Is there any way to plot the figure, but I can differentiate clearly and see the CIs for each value? for example, in the first category of x2 variable, all values are not overlapping each other, but next to each other?
I had provided the code below, as well as the figure, really apologise for the inconvenience. Thank you so much!
regress health c.x1##i.x2, base robust
margins, dydx(health) at(x1=(0(0.25)1)) vsquish
margins, at(x2=(0(1)2) x1=(0(0.25)1)) vsquish
marginsplot, noci xdimension(at(x2)) plot1opts(msymbol(circle)) ///
plot2opts(lpattern(dash) msymbol(circle)) plot3opts(lpattern(solid) ///
msymbol(circle)) plot4opts(msymbol(circle)) plot5opts(lcolor(emidblue) scheme(s1color) ///
lpattern(dash_3dot) msymbol(circle)) ytitle(health) ///
xtitle(x2) ///
I'm using Stata 14.1, and have a question about the marginsplot. I'm trying to plot the interaction effect between x1 (continuous variable) and x2 (categorical) on the outcome (health). The basic idea is to see the moderating effect of x1 on the association between x2 and health. x2 consist of three categories (0 1 2). However, when I plotted the figure through marginsplot, all values is vertically in the same category of x2 variable, and I cannot differentiate the confident interval, since all CIs are overlapping one another.
Is there any way to plot the figure, but I can differentiate clearly and see the CIs for each value? for example, in the first category of x2 variable, all values are not overlapping each other, but next to each other?
I had provided the code below, as well as the figure, really apologise for the inconvenience. Thank you so much!
regress health c.x1##i.x2, base robust
margins, dydx(health) at(x1=(0(0.25)1)) vsquish
margins, at(x2=(0(1)2) x1=(0(0.25)1)) vsquish
marginsplot, noci xdimension(at(x2)) plot1opts(msymbol(circle)) ///
plot2opts(lpattern(dash) msymbol(circle)) plot3opts(lpattern(solid) ///
msymbol(circle)) plot4opts(msymbol(circle)) plot5opts(lcolor(emidblue) scheme(s1color) ///
lpattern(dash_3dot) msymbol(circle)) ytitle(health) ///
xtitle(x2) ///
Comment