Announcement

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

  • Using coefplot command for outcomes balance table

    Hi,

    I am trying to generate an outcomes coefficient plot to demonstrate balance across outcomes at baseline using the coefplot command, but I seem to be running into some issues. I'm running several regressions with only two independent variables in each, and want to graph the independent variables on the y-axis with the different dependent variables stacked in-line with their appropriate independent variables.

    I've included sample code below. The issue is that I want the mpg and foreign variables on the same plot but overlayed, and want the legend labels to appear on the y-axis instead.

    Code:
    Code:
     sysuse auto.dta, clear
    
    egen price_std=std(price)
    egen weight_std=std(weight)
    egen length_std=std(length)
    
    reg price_std mpg foreign
    est store price
    
    reg weight_std mpg foreign
    est store weight
    
    reg length_std mpg foreign
    est store length
    
    coefplot price weight length, drop(_cons) xline(0) coeflabel(price="price" weight="weight" length="length") bycoef legend(off)

    I've also attached a working paper I found online below with an example that mimics I want to produce (See Figure 3 on page 42). Source: https://www.nber.org/system/files/wo...785/w25785.pdf
    Attached Files

  • #2
    coefplot is from SSC (FAQ Advice #12). Thanks for the reproducible example. Would be easier to include the y-axis labels as marker labels, but here is a way manually calculating the offsets.

    Code:
    sysuse auto.dta, clear
    egen price_std=std(price)
    egen weight_std=std(weight)
    egen length_std=std(length)
    
    reg price_std mpg foreign
    est store price
    
    reg weight_std mpg foreign
    est store weight
    
    reg length_std mpg foreign
    est store length
    
    set scheme s1color
    
    coefplot (price) (weight) (length), drop(_cons) xline(0) ///
    ylabel(0.75 "price" 1 "weight" 1.25 "length" 1.75 "price" ///
    2 "weight" 2.25 "length", notick) nokey text(1 -1.35 ///
    "Outcome 1", orientation(vertical)) text(2 -1.35 ///
    "Outcome 2", orientation(vertical)) ysc(outergap(5))

    Click image for larger version

Name:	Graph.png
Views:	1
Size:	15.4 KB
ID:	1657590

    Comment


    • #3
      Hi Andrew,

      Thank you so much for that, that's a huge help!

      Comment

      Working...
      X