PV: Analyse plausible values in surveys

Description Usage Arguments Value Note See Also Examples

Description

Repeats 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.

Usage

1
2
3
withPV(mapping, data, action, rewrite=TRUE, ...)
## Default S3 method:
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 data frame. Methods for withPV dispatch on this argument, so can be written for, eg, survey designs or out-of-memory datasets.

action

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

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.

Note

I would be interested in seeing naturally-occurring examples where rewrite=TRUE does not work

See Also

pisamaths

with.imputationList

Examples

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

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

mitools documentation built on May 2, 2019, 8:52 a.m.

Related to PV in mitools...