Announcement

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

  • How to group by Y instead of Coef using coefplot after margins

    Hello Statalist Friends-

    I have a bar graph that I made after a margins command. It is showing the right data, but the presentation is suboptimal IMO. Currently, the bars are clustered around one of the coefficients (raceet=race/ethnicity) and each different color of bar represents a different model (i.e. raceplot_wrkilf raceplot_wrkelf raceplot_lfiwrk raceplot_lfewrk).

    I would like to reverse this so that instead of three clusters (of coefficients) each comprised of four bars (of models), it is four clusters (of models) of three bars (of coefficients).

    The current graph (that I would like to fix) is attached, and here is my syntax:

    Code:
        foreach y of varlist wrkilf lfiwrk wrkelf lfewrk {
               quietly mixed `y' i.raceet i.educ i.gender agey              || id:  
           
               quietly margins raceet, atmeans grand post
              est sto raceplot_`y'
              }   
        
            coefplot raceplot_wrkilf raceplot_wrkelf raceplot_lfiwrk raceplot_lfewrk, recast(bar) drop(_cons) vert  barw(.2)

    Thank you in advance for your help.


    Kind regards,
    Ben

    Click image for larger version

Name:	Graph.png
Views:	1
Size:	40.7 KB
ID:	1732184

  • #2
    coefplot is from SSC (FAQ Advice #12). Please provide a data example (or a reproducible example using one of Stata's datasets).

    Comment


    • #3
      Andrew Musau Thanks. I was hoping this would be something that would be obvious to someone else. Apparently that isn't the case. That actually makes me feel better: at least I'm not missing something obvious. Cheers

      Comment

      Working...
      X