/*----------------------------------------------------------- Table 4.3 get unweighted estimate of proportion of workplaces with an equal opportunities policy (EOP) but allowing for stratification -------------------------------------------------------------*/ gen const=1 svyset [pweight=const], strata(strata) /*---------------------------------------------------------- now get weighted estimate - strata remain from previous call using svymean to get design effect ------------------------------------------------------------*/ svyset [pweight=est_wt] svydes svyprop eo svymean eo,deff deft /*-------------------------------------------------------------- table 4.4 now weighted table of proportions woth EOP by size of workplace ------------------------------------------------------------*/ svytab nempsize eo, row percent /*------------------------------------------------------- table 4.5 factors compared between eo workplaces and others -------------------------------------------------------*/ svymean eo if ethnic==1 /*--------------------------------------------- note this command is wrong because it does not define a subgroup of the survey On the practical side it fails here because you will get a warning stratum with only one PSU detected Defining subsets of the survey works. It is more forgiving to the odd lonely PSU -------------------------------------------------*/ svymean female,by(eo) svymean ethnic,by(eo) svyprop eo,by(disabgrp) /*-------------------------------------------------------------- now weighted linear models to get ses of differences ------------------------------------------------------------*/ svyregress female eo svyregress ethnic eo /*--------- get dummies for linear models----------*/ tab disabgrp, gen(disab) svyregress disab1 eo svyregress disab2 eo svyregress disab3 eo /*-------------------------------------------------------------- same analyses unweighted ------------------------------------------------------------*/ svyset [pweight=const] svymean female,by(eo) svymean ethnic,by(eo) svyprop disabgrp,by(eo) svyregress disab1 eo svyregress disab2 eo svyregress disab3 eo /*-------------------------------------------------------------- table 4.6 now weighted multivariate logistic models ------------------------------------------------------------*/ svyset [pweight=est_wt] svylogit eo female disab2 disab3 ethnic /*-------------------------------------------------------------- now unweighted multivariate logistic models ------------------------------------------------------------*/ svyset [pweight=const] svylogit eo female disab2 disab3 ethnic /*-------------------------------------------------------------- table 4.7adjusted for workplace size now weighted multivariate logistic models ------------------------------------------------------------*/ tab nempsize, gen(numemp) svyset [pweight=est_wt] svylogit eo female disab2 disab3 ethnic numemp2-numemp6 /*-------------------------------------------------------------- now unweighted multivariate logistic models ------------------------------------------------------------*/ svyset [pweight=const] svylogit eo female disab2 disab3 ethnic numemp2-numemp6 /*-------------------------------------------------------------- now mean of eo and by size group allowing for finite population correction Stata requires two things to get the finite population correct 1. A variable with the number of PSUs in the startum 2. Weights that add to the population size first without fpc ------------------------------------------------------------*/ svyset [pweight=grosswt], strata(strata) clear(fpc) svymean eo ,deff deft svymean eo, deff deft by(nempsize) svymean eo, deff deft by(nempsize)srssubpop /*----------- now with fpc--------------------------------*/ svyset [pweight=grosswt] ,fpc(sampfrac) strata(strata) svymean eo, deff deft svymean eo, deff deft by(nempsize) svymean eo, deff deft by(nempsize)srssubpop /*---------------------------------------------------- The two analyses give the different ways that design effects can be defined for subgroups The second one that compares the design with simple random samples of the same size within subgroups is more helpful Note that design effects are much reduced within subgroups. This is because the subgroups are so strogly associated with the weighting factor here. ---------------------------------------------------------*/