Analyse plausible values in surveys
withPV.survey.design.RdRepeats an analysis for each of a set of 'plausible values' in a survey data set, returning a list suitable for mitools::MIcombine. The default method works for both standard and replicate-weight designs but not for two-phase designs.
Usage
# S3 method for class 'survey.design'
withPV(mapping, data, action, rewrite=TRUE, ...)Arguments
- mapping
A formula or list of formulas describing each variable in the analysis that has plausible values. The left-hand side of the formula is the name to use in the analysis; the right-hand side gives the names in the dataset.
- data
A survey design object, as created by
svydesignorsvrepdesign- action
With
rewrite=TRUE, a function taking a survey design object as its only argument, or a quoted expression. Withrewrite=TRUEa function taking a survey design object as its only argument, or a quoted expression with.DESIGNreferring to the survey design object to be used.- rewrite
Rewrite
actionbefore evaluating it (versus constructing new data sets)- ...
For methods
Examples
if(require(mitools)){
data(pisamaths, package="mitools")
des<-svydesign(id=~SCHOOLID+STIDSTD, strata=~STRATUM, nest=TRUE,
weights=~W_FSCHWT+condwt, data=pisamaths)
oo<-options(survey.lonely.psu="remove")
results<-withPV(list(maths~PV1MATH+PV2MATH+PV3MATH+PV4MATH+PV5MATH),
data=des,
action=quote(svyglm(maths~ST04Q01*(PCGIRLS+SMRATIO)+MATHEFF+OPENPS, design=des)),
rewrite=TRUE)
summary(MIcombine(results))
options(oo)
}
#> Error in eval(actioni): object 'des' not found