Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

complete

Extracts Imputed Datasets


Description

complete() function extracts data from an object of the mimids or wimids class.

Usage

## S3 method for class 'mimids'
complete(data, action = 1, include = FALSE, mild = FALSE, all = TRUE, ...)

## S3 method for class 'wimids'
complete(data, action = 1, include = FALSE, mild = FALSE, all = TRUE, ...)

Arguments

data

A mimids or wimids object

action

The imputed dataset number, intended to extract its data, or an action. The input must be a positive integer or a keyword. The keywords include "all" (produces a mild object of the imputed datasets), "long" (produces a dataset with imputed datasets stacked vertically), and "broad" (produces a dataset with imputed datasets stacked horizontally). The default is 1.

include

Whether the original data with the missing values should be included. The input must be a logical value. The default is FALSE.

mild

Whether the return value should be an object of mild class. Please note that setting mild = TRUE overrides action keywords "long", "broad", and "repeated". The default is FALSE.

all

Whether to include observations with a zero estimated weight. The default is TRUE.

...

Ignored.

Details

complete() works by running mice::complete() on the mids object stored within the mimids or wimids object and appending the outputs of the matching or weighting procedure. For mimids objects, the appended outputs include the matching weights, the propensity score (if included), pair membership (if included), and whether each unit was discarded. For wimids objects, the appended output is the estimated weights.

Value

This function returns the imputed dataset within the supplied mimids or wimids objects.

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

Examples

#Loading libraries
library(MatchThem)

#Loading the dataset
data(osteoarthritis)

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

#Matching the multiply imputed datasets
matched.datasets <- matchthem(OSP ~ AGE + SEX + BMI + RAC + SMK,
                              imputed.datasets,
                              approach = 'within',
                              method = 'nearest')

#Extracting the first imputed dataset
matched.dataset.1 <- complete(matched.datasets, n = 1)

MatchThem

Matching and Weighting Multiply Imputed Datasets

v1.0.0
GPL (>= 2)
Authors
Farhad Pishgar [aut, cre], Noah Greifer [aut], Clémence Leyrat [ctb], Elizabeth Stuart [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.