How are BRR weights used in the survey package for R?
r, replicate, survey
Solution
no need to use `as.svrepdesign()` if you have a data frame with the replicate weights already :) you can create the replicate weighted design directly from your data frame.
say you have data with a main weight column called `mainwgt` and 80 replicate weight columns called `repwgt1` through `repwgt80` you could use this --
yoursurvey <-
svrepdesign(
weights = ~mainwgt ,
repweights = "repwgt[0-9]+" ,
type = "BRR",
data = yourdata ,
combined.weights = TRUE
)
-- this way, you don't have to identify the exact column numbers. then you can run normal survey commands like --
svymean( ~variable , design = yoursurvey )
if you'd like another example, here's some example code and an explanatory blog post using the current population survey.
Problem
Does anyone know how to use BRR weights in Lumley's survey package for estimating variance if your dataset already has BRR weights it in? I am working with PISA data, and they already include 80 BRR replicates in their dataset. How can I get as.svrepdesign to use these, instead of trying to create its own? I tried the following and got the subsequent error: ``` dstrat <- svydesign(id=~uniqueID,strata=~strataVar, weights=~studentWeight, data=data, nest=TRUE) dstrat <- as.svrepdesign(dstrat, type="BRR") Error in brrweights(design$strata[, 1], design$cluster[, 1], ..., fay.rho = fay.rho, : Can't split with odd numbers of PSUs in a stratum ``` Any help would be greatly appreciated, thanks.