Announcement

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

  • Help with marginsplot - removing a vertical line (Not yline(0)!)

    Hello,

    So basically I'm having trouble with the output I get when I'm running a marginsplot (I've attached the regression-output and the marginsplot).

    The command is:

    reg Holdningsindeks i.Treatment##c.Tryghedsindeks, robust
    margins, dydx(*) at(Tryghedsindeks=(0(0.1)5))
    marginsplot, yline(0, lpattern(dash) lcolor(black)) graphregion(color(white)) xlabel(#5) recast(line) recastci(rline) ciopts(lpattern(dash)) ytitle("Marginal effekt af afsender") title("Effekt af politisk afsender på holdning givet tryghed") xtitle(Tryghed) noci name(T_uden_konf11)


    ** (The yline(0) is supposed to be there - it's not the problem I'm trying to solve ;-) ). **

    The problem is the vertical green line (y=0,28) and how to remove it.

    The X-variable is 1=Control group, 2=Treatment 1 and 3=Treatment 2.
    The Y-variable is a "position/attitude towards the treatment" from 1-5.
    The Z-variable is the interaction/moderation variable.

    Click image for larger version

Name:	Regressionsoutput.png
Views:	1
Size:	54.5 KB
ID:	1444707


    Click image for larger version

Name:	Maginsplot.png
Views:	1
Size:	70.8 KB
ID:	1444708



    I'm looking forward to hearing from you


    Kind regards
    Mathias

  • #2
    Hi Mathias,

    I'm not sure you want to remove the horizontal green line, given that it is your reference line. But assuming you still want to, there is always the crude way of creating the graph, then editing the graph interactively, and 'hiding' the green line.

    The coding way to achieve this is...
    Code:
    webuse nhanes2 , clear
    regress height c.weight##i.race
    margins , dydx(*) at(weight=(40(5)100))
    marginsplot , plot1opts(lcol(none) msym(none)) ci1opts(lcol(none))
    You can adapt this code for your own context. Let me know if you have any questions.
    Last edited by Matt Warkentin; 18 May 2018, 13:48.

    Comment


    • #3
      Hi Matt,

      Thank you for your quick answer - the reason I want to hide the vertical line/lines (with a control variable, I just added) is more of an aestetic question for my paper/assignment!

      Just one last thing, how do you remove the irrelevant/variables I just "hid" with the command in the "box" beneath the figure. I'm talking about "Tryghedsindeks" and "Koen/Køn".

      The command is so far:
      marginsplot, plot3opts(lcol(none) msym(none)) ci3opts(lcol(none)) plot4opts(lcol(none) msym(none)) ci4opts(lcol(none)) yline(0, lpattern(dash) lcolor(black)) graphregion(color(white)) xlabel(#5) recast(line) recastci(rline) ciopts(lpattern(dash)) ytitle("Marginal effekt af afsender") title("Effekt af politisk afsender på holdning givet tryghed") xtitle(Tryghed) name(T4)




      Click image for larger version

Name:	Model 4 - god.png
Views:	1
Size:	86.8 KB
ID:	1444853


      Last edited by Mathias Jensen; 19 May 2018, 01:19.

      Comment

      Working...
      X