Learn R Programming

mice (version 2.7)

complete: Creates a Complete Flat File from a Multiply Imputed Data Set

Description

Takes an object of class mids, fills in the missing data, and returns the completed data in a specified format.

Usage

complete(x, action=1, include=FALSE)

Arguments

x
An object of class mids as created by the function mice().
action
If action is a scalar between 1 and x$m, the function returns the data with imputation number action filled in. Thus, action=1 returns the first completed data set, action=2 returns the se
include
Flag to indicate whether the orginal data with the missing values should be included. This requires that action is specified as "long", "broad" or "repeated".

Value

  • A data frame with the imputed values filled in. Optionally, the original data are appended.

Details

The argument action can also be a string, which is partially matched as follows: [object Object],[object Object],[object Object]

See Also

mice, mids

Examples

Run this code
# do default multiple imputation on a numeric matrix
imp <- mice(nhanes)          

# obtain first imputated matrix
mat <- complete(imp)         

# fill in the third imputation
mat <- complete(imp, 3)      

# long matrix with stacked complete data
mat <- complete(imp, "long") 

# long matrix with stacked complete data, including the original data
mat <- complete(imp, "long", inc=TRUE)

# repeated matrix with complete data
mat <- complete(imp, "r")    

# for numeric data, produces a blocked correlation matrix, where
# each block contains of the same variable pair over different
# multiple imputations.
cor(mat)

Run the code above in your browser using DataLab