Announcement

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

  • marginsplot (interaction plot) change marker position or symbols

    Hello all,

    I would like to seek help in margins plot. I searched the forum but could not find the answer.

    I wanted to have a graph similar like this, looking at the effect of chronic conditions depend on mental health and income group on outcomes. graph.png


    I tried two sets of code but were unable to make it.

    The first one
    Code:
     
    xtreg score i.chronic##i.Depr i.age gender i.edu i.income
    margins, at(Depr = (0/1) chronic = (0/3) ) over(income) 
    marginsplot, xdimension(chronic income ) recast(scatter)  recastci(rspike) ///
    legend(order(1 "no depression " 2 " depression " )) ///
    ciopts(lc(black)) ///
    plot1opts(msymbol(D) mcolor("gs0") msize(small) ) ///
    plot2opts(msymbol(D) mcolor("gs10") msize(small) ) ///
    xtitle("number of chronic diseases", margin(3 0 3 3) ) ytitle("score") ///
    xlabel( 2.5 "0"  6.5 "1" 10.5 "2"  14.5"3+")
    I got the below, So wondering how can I change marker color symbol for each income group?
    graph1.png



    The second one
    Code:
    xtreg score i.chronic##i.Depr i.age gender i.edu i.income
    margins, at(Depr = (0/1) chronic = (0/3) ) over(income) 
    marginsplot, xdimension(chronic )  recast(scatter)  recastci(rspike) ///
    legend(order(1 "no depression Q4" 2 "no depression Q3" 3 "no depression Q2" 4 "no depression Q1" ///
    5 "depression Q4" 6 "depression Q3" 7 "depression Q2" 8 "depression Q1" )) ///
    ciopts(lc(black)) ///
    plot1opts(msymbol(D) mcolor("gs0") msize(small) ) ///
    plot2opts(msymbol(D) mcolor("gs5") msize(small) ) ///
    plot3opts(msymbol(D) mcolor("gs10") msize(small)) ///
    plot4opts(msymbol(D) mcolor("navy") msize(small)) ///
    plot5opts(msymbol(O) mcolor("gs0") msize(small)) ///
    plot6opts(msymbol(O) mcolor("gs5") msize(small)) ///
    plot7opts(msymbol(O) mcolor("gs10") msize(small)) ///
    plot8opts(msymbol(O) mcolor("navy") msize(small)) ///
    xtitle("chronic diseases", margin(3 0 3 3) )

    And I got. So wondering if I can change markers position?
    graph2.png



    Many thanks in advance.

    Cheers,
    Tianxin
Working...
X