with.wimids: Evaluates an Expression in Weighted Imputed Datasets

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/with.wimids.R

Description

The with() function performs a computation on each of the m imputed datasets. The typical sequence of steps to estimate weights of observations of the imputed datasets are:

  1. Impute the missing data points by the mice function (from the mice package), resulting in a multiple imputed dataset (an object of the mids class);

  2. Estimate weights of observations in the imputed datasets by the weightitmice() function, resulting in an object of the wimids class;

  3. Fit the model of interest (scientific model) on each weighted dataset by the with() function, resulting in an object of the mira class;

  4. Pool the estimates from each model into a single set of estimates and standard errors, resulting in an object of the mipo class.

Usage

1
2
## S3 method for class 'wimids'
with(data, expr, ...)

Arguments

data

This argument specifies an object of the wimids class, typically produced by a previous call to the function weightitmice().

expr

This argument specifies an expression of the usual syntax of R formula. See help(formula) for details.

...

Additional arguments to be passed to expr.

Details

The with() performs a computation on each of the imputed datasets.

Value

This function returns an object of the mira class (multiply imputed repeated analyses).

Author(s)

Extracted from the mice package written by Stef van Buuren et al. with few changes

References

Stef van Buuren and Karin Groothuis-Oudshoorn (2011). mice: Multivariate Imputation by Chained Equations in R. Journal of Statistical Software, 45(3): 1-67. https://www.jstatsoft.org/v45/i03/

See Also

weightitmice

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#Loading the 'dt.osa' dataset
data(dt.osa)

#Imputing missing data points in the'dt.osa' dataset
datasets <- mice(dt.osa, m = 5, maxit = 1,
                 method = c("", "", "mean", "", "polyreg", "logreg", "logreg"))

#Weighting the imputed datasets, 'datasets'
weighteddatasets <- weightitmice(KOA ~ SEX + AGE + SMK, datasets,
                                 approach = 'within', method = 'nearest')

#Merging the dataframe, 'dt.osp', with each imputed dataset of the 'weighteddatasets' object
weighteddatasets <- mergeitmice(weighteddatasets, dt.osp, by = "IDN")

#Analyzing the imputed datasets
models <- with(data = weighteddatasets,
               exp = glm(KOA ~ PTH, weights = inverse.weights,
                         na.action = na.omit, family = binomial))

MatchIt.mice documentation built on Aug. 28, 2019, 1:03 a.m.