Announcement

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

  • Organizing coefplot coefficients by variable rather than model?


    Hi everyone, I was wondering if it was possible to organize coefficients in coefplot by model rather than variable. Take the example produced by the code below. In descending order from the top of the graph, I would like to first show the coefficient for m1 (i.e., married), then the coefficient for m2 (i.e., south), and lastly the coefficients for m3 (i.e., married and south). In addition, I would like the coefficient colors to be constant within variables (e.g., all coefficients for married should be blue and all coefficients for south should be red, regardless of model).

    Any help would be appreciated. I have tried looking but have only found results abour arranging them via size or creating separate graphs (using ||)

    Code:
    sysuse nlsw88,clear
    
    logit union i.married
    margins, dydx(married) post
    estimates store m1
    
    logit union i.south
    margins, dydx(south) post
    estimates store m2
    
    logit union i.married i.south
    margins, dydx(married south) post
    estimates store m3
    
    coefplot m1 m2 m3, xline(0)

  • #2
    coefplot is from SSC (FAQ Advice #12). Thanks for the reproducible example.

    Code:
    sysuse nlsw88,clear
    
    logit union i.married
    margins, dydx(married) post
    estimates store m1
    
    logit union i.south
    margins, dydx(south) post
    estimates store m2
    
    logit union i.married i.south
    margins, dydx(married south) post
    estimates store m3
    
    coefplot (m1\ m3, keep(1.married) label(married))  ///
    (m2 \m3, keep(1.south) label(south)), ///
    aseq swapnames order(m1 m2 m3)
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	24.9 KB
ID:	1773231

    Comment


    • #3
      Thank you so much, Andrew Musau !

      Comment

      Working...
      X