Exact binomial CIs

A general method for creating complex graphs, or even simple graphs that Stata
does not produce with a specific command, is to:

1) manage your data using Stata to obtain the points or locations
you wish to plot

2) plot the points or locations using the appropriate twoway
plotttype - rbar for a range plotted with a bar,
scatter for a set of points, etc.

o Manage data or results

In this example we will use statsby to collect exact binomial confidence
intervals for a proportion and plot the results using twoway. (click
each command below in sequence.)

. sysuse nlsw88 , clear

. statsby "ci union , binomial"
"proportion=(r(mean)) lb=(r(lb)) ub=(r(ub)) ,"
"by(occupation) clear"

. label variable lb ""

. label variable ub ""

. label variable proportion ""

o Use twoway to plot the results

To see variations on graphs of these proportions and sometimes their
confidence intervals click the following graph commands.

(Note that on Unix-based systems those graphs specifying
an angle on the axis labels will not draw the labels correctly in the Graph
window; they will, however, produce correct files for export if you use the
graph export command.)

. twoway bar proportion occupation

. twoway bar proportion occupation , barwidth(.75)
xlabel(1(1)13 , valuelabel angle(45))
graphregion(margin(l=12))

. twoway bar proportion occupation , barwidth(.75) ||
rcap lb ub occupation ,
xlabel(1(1)13 , valuelabel angle(45))
graphregion(margin(l=12))

. twoway bar proportion occupation ,
horiz barwidth(.75) ||
rcap lb ub occupation , horiz
ylabel(1(1)13 , valuelabel angle(0) nogrid)
ytitle("") xlabel(,grid)
legend(label(1 "proportion"))

. twoway scatter occupation proportion ||
rcap lb ub occupation , horiz
ylabel(1(1)13 , valuelabel angle(0) nogrid)
ytitle("") xlabel(,grid)
legend(label(1 "proportion"))

<< index >>