Aliases: subset.survey.design subset.svyrep.design [.survey.design
### ** Examples data(fpc) dfpc<-svydesign(id=~psuid,strat=~stratid,weight=~weight,data=fpc,nest=TRUE) dsub<-subset(dfpc,x>4) summary(dsub)
Stratified Independent Sampling design (with replacement) subset(dfpc, x > 4) Probabilities: Min. 1st Qu. Median Mean 3rd Qu. Max. 0.2500 0.2708 0.3333 0.3056 0.3333 0.3333 Stratum Sizes: 1 2 obs 4 2 design.PSU 5 3 actual.PSU 4 2 Data variables: [1] "stratid" "psuid" "weight" "nh" "Nh" "x"
svymean(~x,design=dsub)
mean SE x 6.195 0.7555
## These should give the same domain estimates and standard errors svyby(~x,~I(x>4),design=dfpc, svymean)
I(x > 4) x se FALSE FALSE 3.314286 0.3117042 TRUE TRUE 6.195000 0.7555129
summary(svyglm(x~I(x>4)+0,design=dfpc))
Call: svyglm(formula = x ~ I(x > 4) + 0, design = dfpc) Survey design: svydesign(id = ~psuid, strat = ~stratid, weight = ~weight, data = fpc, nest = TRUE) Coefficients: Estimate Std. Error t value Pr(>|t|) I(x > 4)FALSE 3.3143 0.3117 10.63 0.000127 *** I(x > 4)TRUE 6.1950 0.7555 8.20 0.000439 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 (Dispersion parameter for gaussian family taken to be 2.557379) Number of Fisher Scoring iterations: 2
data(api) dclus1<-svydesign(id=~dnum, weights=~pw, data=apiclus1, fpc=~fpc) rclus1<-as.svrepdesign(dclus1) svymean(~enroll, subset(dclus1, sch.wide=="Yes" & comp.imp=="Yes"))
mean SE enroll 534.56 36.248
svymean(~enroll, subset(rclus1, sch.wide=="Yes" & comp.imp=="Yes"))
mean SE enroll 534.56 40.398