I am working on quarterly Labor Force Survey from 2008 to 2010 .
I would like to create a table for summary statistics for 4 subpopulation of my data ( Male before, Male After , Female before and Female After ) where After is the variable Post.
My dataset is already svyset , but the estpost tabstat doesn't seem to support svy , only the tabulate but not tabstat.
I use Stata 16 and the ESTPOST command.
The code I used is below ;
Code:
generate the column identifiers by flag gen flag=1 if sex==1 & post==0 replace flag=2 if sex==1 & post==1 replace flag=3 if sex==0 & post==0 replace flag=4 if sex==0 & post==1 estpost tabstat age mar_st reg* edu2 edu3 edu4 edu6 edu8 lfs unemployed [aw=int_wt], by(flag) statistics(mean sd N) columns(statistics) nototal esttab using table1.rtf, replace main(mean) aux(sd) unstack nomtitle nonumber label nogaps title("Discriptive statistics for sample ")
and the results were as below;
Discriptive statistics for sample
1 | 2 | 3 | 4 | |
age | 27.10 | 26.42 | 27.53 | 26.72 |
(19.26) | (19.21) | (19.02) | (19.02) | |
Marital status | 2.049 | 2.048 | 2.423 | 2.381 |
(0.986) | (0.984) | (1.403) | (1.409) | |
region | 4.142 | 4.155 | 4.127 | 4.137 |
(1.813) | (1.809) | (1.812) | (1.803) | |
region==Greater Cairo | 0.157 | 0.155 | 0.159 | 0.156 |
(0.364) | (0.362) | (0.365) | (0.363) | |
region==Alex & Suez Canal | 0.0769 | 0.0770 | 0.0774 | 0.0773 |
(0.266) | (0.267) | (0.267) | (0.267) | |
region==Urban Upper Egypt | 0.0996 | 0.0964 | 0.102 | 0.0998 |
(0.299) | (0.295) | (0.302) | (0.300) | |
region==Urban Lower Egypt | 0.0873 | 0.0910 | 0.0873 | 0.0910 |
(0.282) | (0.288) | (0.282) | (0.288) | |
region==Rural Upper Egypt | 0.309 | 0.307 | 0.307 | 0.308 |
(0.462) | (0.461) | (0.461) | (0.462) | |
region==Rural Lower Egypt | 0.250 | 0.255 | 0.252 | 0.252 |
(0.433) | (0.436) | (0.434) | (0.434) | |
region==Frontier | 0.0194 | 0.0186 | 0.0162 | 0.0156 |
(0.138) | (0.135) | (0.126) | (0.124) | |
educ_st==Illitrate | 0.161 | 0.149 | 0.292 | 0.267 |
(0.367) | (0.356) | (0.455) | (0.442) | |
educ_st==Read and Write | 0.139 | 0.134 | 0.105 | 0.0982 |
(0.346) | (0.341) | (0.307) | (0.298) | |
educ_st==Primary or Prep | 0.172 | 0.172 | 0.144 | 0.148 |
(0.377) | (0.378) | (0.351) | (0.355) | |
educ_st==Technical/Vocational Diploma | 0.172 | 0.174 | 0.139 | 0.148 |
(0.377) | (0.379) | (0.346) | (0.355) | |
educ_st==College Degree | 0.0846 | 0.0880 | 0.0638 | 0.0718 |
(0.278) | (0.283) | (0.244) | (0.258) | |
Labor Force | 0.729 | 0.752 | 0.227 | 0.228 |
(0.445) | (0.432) | (0.419) | (0.419) | |
All Unemployed | 0.0421 | 0.0383 | 0.0521 | 0.0559 |
(0.201) | (0.192) | (0.222) | (0.230) | |
Observations | 1008611 |
* p < 0.05, ** p < 0.01, *** p < 0.001
My problem is that the above doesn't include the svy settings and give results very different from using for example the svy commands below
Code:
svy, subpop (if sex==1 & post==0): mean age lfs unemployed reg* ( for any of the 4 subpopulations above ) , I get different results .
The following
Survey: Mean estimation
Number of strata = 154 Number of obs = 852,739
Number of PSUs = 7,427 Population size = 194,685,642
Subpop. no. obs = 273,166
Subpop. size = 62,671,956.6
Design df = 7,273
--------------------------------------------------------------
| Linearized
| Mean Std. Err. [95% Conf. Interval]
-------------+------------------------------------------------
age | 33.70677 .0251904 33.65739 33.75615
lfs | .7654193 .0011021 .7632589 .7675798
unemployed | .0420523 .000682 .0407153 .0433892
region | 4.06441 .0108864 4.04307 4.085751
reg1 | .1657978 .0026677 .1605684 .1710272
reg2 | .0814624 .0011528 .0792026 .0837221
reg3 | .1037393 .0018627 .1000878 .1073908
reg4 | .087979 .0017812 .0844873 .0914708
reg5 | .3117424 .0020266 .3077696 .3157151
reg6 | .2311122 .0018523 .2274812 .2347432
reg7 | .018167 .0015668 .0150955 .0212385
--------------------------------------------------------------
Note: Strata with single sampling unit centered at overall
mean.
.
Any idea on how can I incorporate svy settings to get svy like results using estpost ? Or what am I doing wrong in the above.
Thanks,
0 Response to Estpost for summary statistics with complex design survey data
Post a Comment