withPV.survey.design: Analyse plausible values in surveys

Description Usage Arguments Value See Also Examples

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

1
2
## 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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
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)
}

Example output

Loading required package: grid
Loading required package: Matrix
Loading required package: survival

Attaching package:surveyThe following object is masked frompackage:graphics:

    dotchart

Loading required package: mitools
Multiple imputation results:
      withPV.survey.design(list(maths ~ PV1MATH + PV2MATH + PV3MATH + 
    PV4MATH + PV5MATH), data = des, action = quote(svyglm(maths ~ 
    ST04Q01 * (PCGIRLS + SMRATIO) + MATHEFF + OPENPS, design = des)), 
    rewrite = TRUE)
      MIcombine.default(results)
                          results         se       (lower      upper) missInfo
(Intercept)          4.729436e+02 18.0393855  437.5845852 508.3025560      2 %
ST04Q01Male          5.268461e+01 21.0694092   11.3661653  94.0030492      4 %
PCGIRLS              5.974293e+01 15.4147851   29.4989531  89.9869166      6 %
SMRATIO              3.552268e-02  0.1072370   -0.1747109   0.2457563      3 %
MATHEFF              4.736517e+01  2.7066937   42.0474147  52.6829207      9 %
OPENPS               1.317289e+01  2.6812880    7.9012159  18.4445630     11 %
ST04Q01Male:PCGIRLS -1.109811e+02 28.6338917 -167.1340465 -54.8282283      4 %
ST04Q01Male:SMRATIO  4.391909e-03  0.1179117   -0.2267333   0.2355171      2 %

survey documentation built on July 19, 2021, 9:06 a.m.