Learn R Programming

MatchThem (version 1.2.1)

as.wimids: Create a wimids object

Description

Creates a wimids object from a list of weightit objects and an imputed dataset.

Usage

as.wimids(x, ...)

# S3 method for default as.wimids(x, datasets, ...)

Value

A wimids object.

Arguments

x

A list of weightit objects, each the output of a call to WeightIt::weightit() on an imputed dataset.

...

Ignored.

datasets

The datasets containing the exposure and covariates mentioned in the formula. This argument must be an object of the mids or amelia class, which is typically produced by a previous call to mice() from the mice package or to amelia() from the Amelia package (the Amelia package is designed to impute missing data in a single cross-sectional dataset or in a time-series dataset, currently, the MatchThem package only supports the former datasets).

Details

The weighted datasets are stored as though weightthem() was called with approach = "within".

See Also

weightthem(), wimids, WeightIt::weightit()

Examples

Run this code

#Loading the dataset
data(osteoarthritis)

#Multiply imputing the missing values
imputed.datasets <- mice::mice(osteoarthritis, m = 5,
                               printFlag = FALSE)

#Matching the multiply imputed datasets manually
weight.list <- lapply(1:5, function(i) {
  WeightIt::weightit(OSP ~ AGE + SEX + BMI + RAC + SMK,
                     mice::complete(imputed.datasets, i),
                     method = 'glm',
                     estimand = 'ATT')
})

#Creating wimids object
weighted.datasets <- as.wimids(weight.list,
                               imputed.datasets)

Run the code above in your browser using DataLab