Announcement

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

  • Change line options for one of the variables in marginsplot

    Hi,

    The code I'm currently using to plot marginal effects is:

    marginsplot, recastci(rarea) recast(line) ciopts(astyle(ci) fintensity(%50) acolor(%50) )

    Could someone please tell me the code to change the line border for one of the sets of confidence intervals to be something other than a line (a dot or dash etc). I can change it in the graph editor, but I would prefer to use the code.

    Thanks,,

    Ciaran

  • #2
    Please note the FAQ advice to present a reproducible example when asking a question (FAQ Advice #12). marginsplot allows twoway options, so you want to use the plot#opts() option, where # represents the particular plot that you want to modify. Here is a reproducible example:

    Code:
    webuse nhanes2, clear
    logistic highbp sex##agegrp##c.bmi
    margins sex, at(bmi=(10(5)65))
    marginsplot, recast(line) recastci(rarea) plot2opts(lpattern(dash) lcolor(black)) scheme(s1color)

    Res.:
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	97.2 KB
ID:	1586416

    Comment


    • #3
      Hi, thanks for your reply. This is what I'm looking for, except I want to change the border around one of the confidence intervals, rather than the center slope line.

      Comment


      • #4
        Code:
        webuse nhanes2, clear
        logistic highbp sex##agegrp##c.bmi
        margins sex, at(bmi=(10(5)65))
        marginsplot, recast(line) recastci(rarea) ci2opts(lpattern(dash) lcolor(black)) scheme(s1color)
        Res.:

        Click image for larger version

Name:	Graph.png
Views:	1
Size:	37.9 KB
ID:	1586440

        Comment


        • #5
          I have a similar problem, which however doesn't seem to be solvable by using Andrew's solution. I am running the following -marginsplot- command after a conditional logit model:

          Code:
          marginsplot, xtitle("Cultural tightness", bmargin(small)) xlabel(#6, grid glwidth(vthin) glcolor(gs11%40) glpattern(shortdash)) ylabel(, grid glwidth(vthin) glcolor(gs11%40) glpattern(shortdash)) title("") ytitle("Average marginal effect of" "recent investments") graphregion(color(white)) plotregion(color(white)) plot1opts(lpattern(solid) lwidth(medthin) lcolor(dknavy) msymbol(smcircle) msize(small) mcolor(dknavy)) ci1opts(recast(rarea) acolor(gs13%40) lcolor(none)) saving(cult_tight_dydx, replace)
          The command produces the plot below, which is almost exactly what I am trying to obtain. The only difference is that I'd need to eliminate that grey outline around the confidence intervals. -ci1opts- however completely ignores the -lcolor(none)- option I set. I suppose I am doing something wrong, and there is a way to do this programmatically, as when the graph is saved I can easily open it and remove that line manually. But I've been pulling my hair because anything I have tried so far to achieve this with -marginsplot- has failed.

          Many thanks for any help you may be able to offer.

          Click image for larger version

Name:	cult_tight_dydx.png
Views:	1
Size:	40.9 KB
ID:	1717289

          Comment


          • #6
            I think I am able to answer my own question: it's -lwidth(none)- that does the trick, not -lcolor(none)-. For some reason, -lcolor()- does not work to this end.

            Code:
            marginsplot, xtitle("Cultural tightness", bmargin(small)) xlabel(#6, nogrid) ylabel(, nogrid) title("") ytitle("Average marginal effect of" "recent investments") graphregion(color(white)) plotregion(lcolor(black)) plot1opts(lpattern(solid) lwidth(medthin) lcolor(dknavy) msymbol(smcircle) msize(small) mcolor(dknavy)) recastci(rarea) ci1opts(lwidth(none) acolor(gs13%40)) saving(cult_tight_dydx, replace)

            Comment

            Working...
            X