withPV.survey.design {survey}R Documentation

Analyse plausible values in surveys

Description

Repeats 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 svydesign or svrepdesign

action

With rewrite=TRUE, a function taking a survey design object as its only argument, or a quoted expression. With rewrite=TRUE a function taking a survey design object as its only argument, or a quoted expression with .DESIGN referring to the survey design object to be used.

rewrite

Rewrite action before evaluating it (versus constructing new data sets)

...

For methods

Value

A list of the results returned by each evaluation of action, with the call as an attribute.

See Also

with.svyimputationList

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)
}

[Package survey version 4.1-1 Index]