Announcement

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

  • Offset values on x axis in marginsplot?

    Hello all,

    I am trying to present a graph using marginsplot but I find the values from an interaction stack on top of each other. I know that this is supposed to be and that it might be useful when comparing two trends over different values of a variables, but I'm dealing strictly with categories. Here's an idea of what I'm trying to do:

    Code:
    sysuse auto
    reg price i.rep78##i.foreign
    margins rep78#foreign
    marginsplot, recast(scatter)
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	20.6 KB
ID:	1447020


    As you can see from the chart, domestic and foreign are on top of each other, which means their CIs overlap. Is there anyway to use marginsplot so that all values of domestic are offset by -.1 on the x axis and that all values of foreign are offset by +.1 on the x axis? It would make for a more understandable chart in regards to comparing domestic and foreign over each categories... In my dataset, the interaction is between a variable with three categories and one with four categories... so having 4 markers on top of each other is even harder to read.

    I know there must be a way to do this with coefplot, but I couldn't find it. I thought I'd ask if there was an "easy" way with marginsplot.

    Thanks!
    JP Gauvin

  • #2
    Hello JP. See this thread: Using an offset of 0.25 for your example produces a pretty nice looking graph.

    Code:
    clear *
    sysuse auto
    reg price i.rep78##i.foreign
    margins rep78#foreign
    mplotoffset, offset(0.25) recast(scatter)
    HTH.


    --
    Bruce Weaver
    Email: [email protected]
    Version: Stata/MP 18.5 (Windows)

    Comment


    • #3
      Thank you Bruce, this is exactly what I needed!

      JP

      Comment

      Working...
      X