As an example we use data from Stata, based on the NHANES 2 study. This data file has a set of 32 replicates based on the BRR method.
The replicate weights are in columns 56 to 87 of the data file. In this case it is easiest to specify the variables and replicate weights as separate data frames rather than as formulas. The overall analysis weights are in the variable finalwgt and this is specified as the weights argument. The BRR weights already incorporate the analysis weights (ie they are 2*finalwgt and 0 rather than 2 and 0), so we use combined.weights=TRUE
> hanes<-read.dta("nhanes2brr.dta") > brrhanes<-svrepdesign(variables=hanes[,1:55], repweights=hanes[,56:87], type="BRR",combined.weights=TRUE, weights=hanes$finalwgt) > brrhanes Call: svrepdesign(variables = hanes[, 1:55], repweights = hanes[, 56:87], type = "BRR", combined.weights = TRUE, weights = hanes$finalwgt) Balanced Repeated Replicates with 32 replicates.
The summary method shows the variable names.
> summary(brrhanes) Call: svrepdesign(variables = hanes[, 1:55], repweights = hanes[, 56:87], type = "BRR", combined.weights = TRUE, weights = hanes$finalwgt) Balanced Repeated Replicates with 32 replicates. Variables: [1] "sampl" "region" "smsa" "location" "houssiz" "sex" [7] "race" "age" "height" "weight" "bpsystol" "bpdiast" [13] "tcresult" "tgresult" "hdresult" "hgb" "hct" "tibc" [19] "iron" "hlthstat" "heartatk" "diabetes" "sizplace" "finalwgt" [25] "leadwt" "corpuscl" "trnsfern" "albumin" "vitaminc" "zinc" [31] "copper" "porphyrn" "lead" "female" "black" "orace" [37] "fhtatk" "hsizgp" "hsiz1" "hsiz2" "hsiz3" "hsiz4" [43] "hsiz5" "region1" "region2" "region3" "region4" "smsa1" [49] "smsa2" "smsa3" "rural" "loglead" "highbp" "agegrp" [55] "highlead"We can now compute some summary statistics
> svymean(~height+weight, brrhanes) mean SE height 168.460 0.1466 weight 71.901 0.1656 > svymean(~race, brrhanes) mean SE raceWhite 0.879154 0.0167 raceBlack 0.095506 0.0128 raceOther 0.025340 0.0106 > brrhanes<-update(brrhanes, hypertension=bpsystol>140 | bpdiast>90) > svytotal(~hypertension, brrhanes) total SE hypertensionFALSE 86223743 2306597 hypertensionTRUE 30933770 1496350