Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Marginsplot, jitters and confident interval

    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) ///
    Attached Files
    Last edited by shaotzu Yu; 11 May 2017, 06:30.

  • #2
    I created a modified version of Stata's marginsplot, which I call mplotoffset, that offsets horizontally the multiple plots; I think this is exactly what you are looking for.

    Here's an example of what it produces:
    Code:
    oprobit rep78 mpg price weight
    margins , at(mpg=(10(5)40))
    mplotoffset, offset(0.5) recast(scatter)

    I have sent it just now to be included in SSC; if you would like a copy before it is available there just message me.

    Comment


    • #3
      Dear Nicholas, dear all,

      I downloaded the program mplotoffset from SSC. However, when I try to run it (also by using the examples in the help file) Stata replies with

      _predict not found
      r(111);

      Am I doing something wrong? I use Stata version 13.

      Best,
      Peter

      Comment

      Working...
      X