Add Confidence Intervals by Category

You can add a range plot with capped spikes on top of a scatter graph to add confidence intervals to your graph.

To generate this graph in Stata, use the following commands:

sysuse nlsw88, clear
 
local ytitle "`: variable label wage'"
 
replace grade = 3 if grade == 0
statsby mean=r(mean) ub=r(ub) lb=r(lb) N=r(N), by(grade) clear: ci means wage
 
label define gradelbl 3 "0"
label values grade gradelbl
 
twoway rcap ub lb grade || scatter mean grade, ytitle(`ytitle') legend(off) subtitle("95% confidence intervals for mean", place(w)) xlabel(3(1)18, valuelabels)