Announcement

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

  • Quantile bar graph

    Hello everyone,
    I have five income quantiles (x-axis), three load-shedding status (category) and an index (y axis). I have been trying to get rid of '6' from the x axis, but I have not been able to do so. I wonder if someone could help me to do it. I mean is there any way to restrict the range of x axis? For example from 1 to 5 in my case here?
    The codes I used to make this graph:

    collapse (mean) meandir_index= dir_index (sd) sddir_index=dir_index (count) n=dir_index, by(quintileincome loadshedding)

    generate hidir_index = meandir_index + invttail(n-1,0.025)*(sddir_index / sqrt(n))
    generate lowdir_index = meandir_index - invttail(n-1,0.025)*(sddir_index / sqrt(n))


    graph bar meandir_index, over(quintileincome) over(loadshedding)
    graph bar meandir_index, over(quintileincome) over(loadshedding) asyvars


    graph twoway (bar meandir_index quintileincome) (rcap hidir_index lowdir_index quintileincome), by(loadshedding)



    Click image for larger version

Name:	Fig_7a.jpg
Views:	1
Size:	30.7 KB
ID:	1642340

  • #2
    There is no data example here, contrary to FAQ Advice #12. (The collapsed dataset is easily small enough to show.)

    I don't know exactly what you are doing wrong but it may be that all you need is an explicit xla(1/5) in the last command.

    That said, I wouldn't do it your way.

    1. There is no need for do-it-yourself confidence intervals when ci means will do it for you.

    2. The bar and bar design is crude. especially as your results fall easily within the interval from about 0.55 to 0.8 so that comparison with zero isn't really fundamental.
    Google detonator plot and dynamite plot for critiques of the design.

    3. scheme s2color is in many ways a poor default, unless you really like it.

    4. by() doesn't allow easy comparisons given your other predictor.

    Here is an analog[ue] of your problem, with a bit of easy work to set up offsets

    Code:
    webuse nlswork, clear 
    
    xtile age_bin5=age, nq(5)
    statsby , by(age_bin5 race) clear : ci means ln_wage 
    
    gen age_bin5_0 = age_bin5 - 0.2
    gen age_bin5_1 = age_bin5 + 0.2 
    
    set scheme s1color 
    
    scatter mean age_bin5_0 if race==1, ms(O) mc(orange)     ///
    || scatter mean age_bin5 if race==2, ms(D) mc(black)  ///
    || scatter mean age_bin5_1 if race==3, ms(S) mc(blue)  /// 
    || rcap ub lb age_bin5_0 if race==1, lc(orange)    ///
    || rcap ub lb age_bin5 if race==2, lc(black)  /// 
    || rcap ub lb age_bin5_1 if race==3, lc(blue)   /// 
    xli(1.5(1)4.5, lc(gs8) lw(thin)) xla(, tlc(none)) /// 
    legend(order(1 "white" 2 "black" 3 "other")) legend(row(1) pos(11)) /// 
    xtitle(Age quintiles) ytitle(Wage (ln scale)) yla(, ang(h)) xsc(r(0.6 5.4))

    Click image for larger version

Name:	doitthisway.png
Views:	1
Size:	19.9 KB
ID:	1642356

    Comment

    Working...
    X