I frequently find that I want to produce line graphs of times series of categorical variables using survey data.
For instance, to just use a simple example, let's say I want to use the American Community Survey (a large, nationally-representative household survey of the US population) to produce a line graph of the annual rate of uninsurance among 4 different race/ethnic groups. Here, race4cat is a 4-level categorical variable of race. Uninsured = 1 if uninsured and 0 if insured. I have already svyset the data using pweights, cluster, and strata variables. Year is 2009-2018.
Code:
svy, subpop(if race4cat == 1): tabulate uninsured year, column percent svy, subpop(if race4cat == 2): tabulate uninsured year, column percent svy, subpop(if race4cat == 3): tabulate uninsured year, column percent svy, subpop(if race4cat == 4): tabulate uninsured year, column percent
Code:
collapse (mean) uninsuredavg=uninsured [pweight=perwt], by(year race4cat)
Code:
twoway (connected uninsuredavg year if race4cat == 1) /// (connected uninsuredavg year if race4cat == 2), /// (connected uninsuredavg year if race4cat == 3), /// (connected uninsuredavg year if race4cat == 4)
My two questions are:
1. Is there a less roundabout way to graph survey tabulation results than collapsing the database as I have done?
2. Assuming no, is there a way to graph confidence intervals?
Many thanks in advance!
Adam
0 Response to Graphing svy tabulation results including 95% confidence intervals
Post a Comment