Jun 20, 2014

Random graphs (26): Plot means by country

use cntry stflife using "ESS1e06.3_F1.dta", clear

encode cntry, gen(country)  // De-string country identifier

preserve

statsby mean_ = _b[_cons] ///
        loci  = (_b[_cons] - 1.96 * _se[_cons]) ///
        hici  = (_b[_cons] + 1.96 * _se[_cons]) ///
      , by(country) total clear: /// // -total- fits model for total sample
        regress stflife

replace country = 1000 if country == .  // Label mean from total sample
label define country 1000 "{bf: Total}", modify // Label mean from total sample

egen order_ = rank(-mean_), unique
labmask order_, value(country) decode

twoway (dot mean_ order_, msize(vsmall)) ///
       (rcap loci hici order_) ///
     , legend(off) xlabel(1/23, valuelabels ang(v)) ///
       ylabel(,format(%6.1f)) name(lifesat, replace)  ///
       xtitle("") ytitle("Life satisfaction (avg.)")

restore