Learn R Programming

MatchThem (version 0.8.1)

with.wimids: Evaluates an Expression in Weighted Imputed Datasets

Description

The with() function performs a statistical computation on the n imputed datasets of the wimids object. The typical sequence of steps to do a weighting procedure on the imputed datasets are:

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

  2. Estimate weights of observation in each imputed dataset using a weighting model by the weightthem() function, resulting in an object of the wimids class;

  3. Fit the statistical model of interest 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

# S3 method for wimids
with(data, expr, ...)

Arguments

data

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

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.

Value

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

Details

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

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

weightthem

Examples

Run this code
# NOT RUN {
#Loading the dataset
data(osteoarthritis)

#Multiply imputing the missing values
imputed.datasets <- mice(osteoarthritis, m = 5, maxit = 10,
                         method = c("", "", "mean", "polyreg", "logreg", "logreg", "logreg"))

#Estimating weights of observations in the multiply imputed datasets
weighted.datasets <- weightthem(OSP ~ AGE + SEX + BMI + RAC + SMK, imputed.datasets,
                                approach = 'within', method = 'ps')

#Analyzing the weighted datasets
models <- with(data = weighted.datasets,
               exp = glm(KOA ~ OSP, weights = weights, family = binomial))
# }

Run the code above in your browser using DataLab