Dear statalist,
I am trying to calcualte bar graphs with standard errors in Stata 14 using survey data.
The easiest way I can think of is the following:
Is this right or am I missing anything? This way the upper and lower bound of the CI seem really close.
Thanks!
I am trying to calcualte bar graphs with standard errors in Stata 14 using survey data.
The easiest way I can think of is the following:
Code:
*Convert pweights into fweights local k = 2 gen fwt = round(10^(`k')*weight,1) *Collapse data collapse (mean) meanX = X (sd) sdX = X (count) n = X [fw=fwt], by(region) *Upper and lower values of confidence interval gen hiX = meanX + invttail(n-1,0.025)* sdX / sqrt(n) gen lowX = meanX - invttail(n-1,0.025)* sdX / sqrt(n) *create bar graph graph twoway (bar meanX region if region==1) /// (bar meanX region if region==2) /// (bar meanX region if region==3) /// (bar meanX region if region==4)
Thanks!
Comment