Announcement

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

  • #16
    It's possible to tinker with such plots indefinitely. Here is another version. I've done Molly Jeffery's v2 but using egen, tag() (it's the same graph) and changed some details in a further v3, mainly

    1. There is enough space to show more about the distribution. I've added quantile plots rather than strip plots strict sense without stacking or jittering. (You can think of these as (empirical) (cumulative) distribution function plots on their side if you prefer.) I've also added longer reference lines for the means (of the logarithms, which are thus geometric means for those who think geometric mean income is a natural or at least convenient scale)..

    2. Fewer decimal places for the numeric display.

    The reader should get a fairly clear signal that the distribution for the South is to a good approximation just the other one shifted by about 0.19 on the natural logarithm scale (which is a big deal in income terms, about 21% more).

    Code:
    webuse regsmpl.dta, clear
    set scheme s1color
    keep if year<71
    egen median = median(ln_wage), by(south)
    egen loq = pctile(ln_wage), by(south) p(25)
    egen upq = pctile(ln_wage) , by(south) p(75)
    
    foreach v in median loq upq { 
        gen `v's = strofreal(`v', "%3.2f")
    }
    
    egen min = min(ln_wage)
    egen n = count(ln_wage), by(south) 
    gen shown = "{it:n} = " + string(n) 
    
    gen south2 = south + 0.15
    gen south_njc = south - 0.3
    egen tag = tag(south) 
    
    set scheme s1color 
    
    * Molly Jeffery 
    stripplot ln_wage, msize(small) over(south) box(barw(0.2)) vertical  ///
    addplot(scatter median loq upq south2 if tag, ms(none ..) ///
    mla(median loq upq) mlabcolor(blue ..) mlabsize(*1.2 ..) || ///
    scatter min south if tag, ms(none) mla(shown) mlabcolor(black) mlabsize(*1.2) mlabpos(6)) ///
    xsc(r(. 1.4)) ysc(r(-.5 3)) xla(, noticks) name(v2, replace)
    
    * my suggestion 
    stripplot ln_wage, msize(small) over(south) box(barw(0.06)) boffset(-0.1) pctile(0) cumul cumprob refline height(0.6) vertical ///
    addplot(scatter median loq upq south_njc if tag, ms(none ..) ///
    mla(medians loqs upqs) mlabcolor(blue ..) mlabsize(*1.2 ..) || ///
    scatter min south if tag, ms(none) mla(shown) mlabcolor(black) mlabsize(*1.2) mlabpos(6)) ///
    xsc(r(. 1.4)) ysc(r(-.5 3)) xla(, noticks) yla(, ang(h)) name(v3, replace)

    Click image for larger version

Name:	molly_v2.png
Views:	1
Size:	28.3 KB
ID:	1666392
    Click image for larger version

Name:	molly_v3.png
Views:	1
Size:	29.6 KB
ID:	1666393

    Comment

    Working...
    X