Tips – Stata: How to get rates by multiple variables for complex sampling designed data (-svy-)
If one wants to get the rates of variable 'dmb20' (0, 1) among adults with 'DM' by 'survey' and 'age3grp', he/she can use different ways to get them, three basic approaches are listed below:
1. Use –subpop-
.svy, subpop(if DM==1 & age3grp==1): tab survey dmb20, obs row percent ci format(%5.1f)
.svy, subpop(if DM==1 & age3grp==2): tab survey dmb20, obs row percent ci format(%5.1f)
.svy, subpop(if DM==1 & age3grp==3): tab survey dmb20, obs row percent ci format(%5.1f)
2. Use –proportion-
.svy, subpop(if DM==1): proportion dmb20, over(survey age3grp)
3. Use –ratio-
.svy, subpop(if DM==1): ratio (dmb20/DM), over(survey age3grp)
NOTES: The better part of -svy: tab- is using a logit transform to produce confidence intervals of estimates, which makes the confidence interval always between 0 and 1.
However, the one advantage of using 2 & 3 is you can use post estimation commands, such as -testnl- or -nlcom-, flexibly.
we also can use -svy: total- to get the total numbers like use -count- of -svy: tab-, and followed by the post estimation commands.
No comments:
Post a Comment