Graphics Reference
In-Depth Information
twoway (rcap wageucl wagelcl occ7, blwidth(medthick) msize(large))
(bar mwage occ7, barwidth(.5) bcolor(navy)),
xlabel(1(1)7, valuelabel noticks) xscale(range(.5 7.5))
This graph is similar to the previous
graph, except that we have reversed the
order of the commands, placing the
rcap command first, followed by the
bar command. As a result, only the top
half of the error bar is shown. As in the
previous example, the xlabel() option
determines the labels on the
-axis.
Uses allstates.dta & scheme vg s2c
x
Prof
Mgmt
Sales
Cler.
Operat.
Labor
Other
Occupation recoded into 7 categories
wageucl/wagelcl
(mean) wage
Suppose that we wanted to show the mean wages with confidence intervals broken down
by occupation and whether one graduated college. We use the collapse command to create
the mean, standard deviation, and count by the levels of occ7 and collgrad , and then we
create the upper and lower confidence limits. Finally, the separate command makes sepa-
rate variables for mwage based on whether one graduated college, creating mwage0 (wages for
noncollege grad) and mwage1 (wages for college grad). These commands are shown below,
followed by the command to create the graph.
. vguse nlsw
. collapse (mean) mwage=wage (sd) sdwage=wage
(count) nwage=wage, by(occ7 collgrad)
. generate wageucl = mwage + invttail(nwage,0.025)*sdwage/sqrt(nwage)
. generate wagelcl = mwage - invttail(nwage,0.025)*sdwage/sqrt(nwage)
. separate mwage, by(collgrad)
twoway (line mwage0 mwage1 occ7) (rcap wageucl wagelcl occ7),
xlabel( 1(1)7, valuelabel) xtitle(Occupation) ytitle(Wages)
legend(order(1 "Not College Grad" 2 "College Grad"))
Here, we make a line graph showing the
mean wages for the noncollege
graduates, mwage0 , and the college
graduates, mwage1 , by occupation. We
overlay that with a range plot showing
the confidence interval. The xlabel()
option labels the
-axis with value
labels, and the legend() option labels
the legend.
Uses nlsw.dta & scheme vg s2c
x
Prof
Mgmt
Sales
Cler.
Operat.
Labor
Other
Occupation
Not College Grad
College Grad
The electronic form of this topic is solely for direct use at UCLA and only by faculty, students, and staff of UCLA.
Search WWH ::




Custom Search