Announcement

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

  • Help Please - bar graph with error bars - continuous variable over dichotomic

    Can I please ask someone to help me with us? I can imagine this is a simple thing but it is driving me crazy! I have tried many ways and cannot add the error bars to the bar chart...

    I need a simple two bar chart of the means of two groups (variable 0 and 1) with error bars on top of each bar.

    THank you!

  • #2
    You seem to be looking for what is called a dynamite plot or detonator plot. You can search the list's archives using those terms to see what others have said about how to create them and their advisability.

    You'd typically use a combination of a two-way bar plot and a "range plot with capped spikes" (rcap). An example below has the axes all gussied up and the graph region in white to hide the fact that Stata offsets the y-axis a little.
    Code:
    sysuse auto, clear
    collapse (mean) mean=turn (sem) sem=turn, by(foreign)
    generate error = mean + sem
    
    graph twoway ///
        bar mean foreign, fcolor(none) lcolor(black) lpattern(solid) barwidth(0.25) || ///
        rcap mean error foreign, lcolor(black) ///
            yline(0, lcolor(black) lwidth(medthick)) xscale(range(-0.5 1.5) noline) ///
                xlabel(0 1, valuelabel notick) ///
            yscale(lwidth(medthick)) ylabel(0(10)50, angle(horizontal) nogrid) ///
            legend(off) graphregion(fcolor(white))
    exit
    Depending upon how many observations to plot in each group, you might want to consider this alternative:
    Code:
    sysuse auto, clear
    
    dotplot turn, over(foreign) center mcolor(black) ylabel( , angle(horizontal) nogrid)
    
    exit

    Comment


    • #3
      Joseph is characteristically diplomatic. These plots are widely deplored as revealing so little about the data. In fact, they're distracting. The size of the mean relative to zero is often no issue at all.

      For one positive suggestion among several possible see http://www.statalist.org/forums/foru...sample-t-tests

      Comment

      Working...
      X