Restrict a survey design to a subpopulation, keeping the original design information about number of clusters, strata. If the design has no post-stratification or calibration data the subset will use proportionately less memory.

# S3 method for survey.design
subset(x, subset, ...)
# S3 method for svyrep.design
subset(x, subset, ...)

## Arguments

x

A survey design object

subset

An expression specifying the subpopulation

...

Arguments not used by this method

## Value

A new survey design object

svydesign

## 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:
#>  "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