PV.RdRepeats an analysis for each of a set of 'plausible values' in a data
set, returning a list suitable for MIcombine. That is, the data
set contains some sets of columns where each set are multiple
imputations of the same variable. With
rewrite=TRUE, the action is rewritten to reference each
plausible value in turn; with coderewrite=FALSE a new data set is
constructed for each plausible value, which is slower but more general.
withPV(mapping, data, action, rewrite=TRUE, ...)
# Default S3 method
withPV(mapping, data, action, rewrite=TRUE,...)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.
A data frame. Methods for withPV dispatch on this argument, so
can be written for, eg, survey designs or out-of-memory datasets.
With rewrite=TRUE, a quoted expression specifying the analysis,
or a function taking a data frame as its only argument. With rewrite=FALSE,
A function taking a data frame as its only argument, or a quoted
expression with .DATA referring to the newly-created data frame to be used.
Rewrite action before evaluating it (versus constructing new data
sets)
For methods
A list of the results returned by each evaluation of action, with the call as an attribute.
I would be interested in seeing naturally-occurring examples where
rewrite=TRUE does not work
data(pisamaths)
models<-withPV(list(maths~PV1MATH+PV2MATH+PV3MATH+PV4MATH+PV5MATH), data=pisamaths,
action= quote(lm(maths~ ST04Q01*(PCGIRLS+SMRATIO)+MATHEFF+OPENPS,
data=.DATA)),
rewrite=FALSE
)
summary(MIcombine(models))
#> Multiple imputation results:
#> withPV.default(list(maths ~ PV1MATH + PV2MATH + PV3MATH + PV4MATH +
#> PV5MATH), data = pisamaths, action = quote(lm(maths ~ ST04Q01 *
#> (PCGIRLS + SMRATIO) + MATHEFF + OPENPS, data = .DATA)), rewrite = FALSE)
#> MIcombine.default(models)
#> results se (lower upper)
#> (Intercept) 476.29521866 10.19846456 456.29398235 496.2964550
#> ST04Q01Male 44.43222858 13.56598828 17.74689471 71.1175625
#> PCGIRLS 57.71508114 9.74692372 38.50306520 76.9270971
#> SMRATIO 0.02836617 0.06489931 -0.09889731 0.1556297
#> MATHEFF 47.10385665 2.17240586 42.81677058 51.3909427
#> OPENPS 14.28638523 2.22665478 9.89096602 18.6818044
#> ST04Q01Male:PCGIRLS -107.25844937 14.96948689 -136.80345345 -77.7134453
#> ST04Q01Male:SMRATIO 0.05600631 0.08955382 -0.11960581 0.2316184
#> missInfo
#> (Intercept) 5 %
#> ST04Q01Male 11 %
#> PCGIRLS 14 %
#> SMRATIO 4 %
#> MATHEFF 16 %
#> OPENPS 16 %
#> ST04Q01Male:PCGIRLS 16 %
#> ST04Q01Male:SMRATIO 4 %
## equivalently
models2<-withPV(list(maths~PV1MATH+PV2MATH+PV3MATH+PV4MATH+PV5MATH), data=pisamaths,
action=quote( lm(maths~ST04Q01*(PCGIRLS+SMRATIO)+MATHEFF+OPENPS)), rewrite=TRUE)
summary(MIcombine(models2))
#> Multiple imputation results:
#> withPV.default(list(maths ~ PV1MATH + PV2MATH + PV3MATH + PV4MATH +
#> PV5MATH), data = pisamaths, action = quote(lm(maths ~ ST04Q01 *
#> (PCGIRLS + SMRATIO) + MATHEFF + OPENPS)), rewrite = TRUE)
#> MIcombine.default(models2)
#> results se (lower upper)
#> (Intercept) 476.29521866 10.19846456 456.29398235 496.2964550
#> ST04Q01Male 44.43222858 13.56598828 17.74689471 71.1175625
#> PCGIRLS 57.71508114 9.74692372 38.50306520 76.9270971
#> SMRATIO 0.02836617 0.06489931 -0.09889731 0.1556297
#> MATHEFF 47.10385665 2.17240586 42.81677058 51.3909427
#> OPENPS 14.28638523 2.22665478 9.89096602 18.6818044
#> ST04Q01Male:PCGIRLS -107.25844937 14.96948689 -136.80345345 -77.7134453
#> ST04Q01Male:SMRATIO 0.05600631 0.08955382 -0.11960581 0.2316184
#> missInfo
#> (Intercept) 5 %
#> ST04Q01Male 11 %
#> PCGIRLS 14 %
#> SMRATIO 4 %
#> MATHEFF 16 %
#> OPENPS 16 %
#> ST04Q01Male:PCGIRLS 16 %
#> ST04Q01Male:SMRATIO 4 %