| complete {mice} | R Documentation |
Takes an object of class mids, fills in the missing data, and
returns the completed data in a specified format.
complete(x, action=1, include=FALSE)
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 second
completed data set, and so on.
The value of action can also be one of the following
strings: "long", "broad", "repeated".
See 'Details' for the interpretation. |
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".
|
The argument action can also be a string, which is partially matched as follows:
"long"nrow(x$data)
* x$m
rows and ncol(x$data)+2 columns. The two additional columns are labeled
.id containing the row names of x$data,
and .imp containing the imputation number.
If include=TRUE then nrow(x$data) additional rows with the original data are appended
with .imp set equal to 0.
"broad"nrow(x$data) rows and ncol(x$data) * x$m columns.
Columns are ordered such that the first ncol(x$data) columns corresponds to the first
imputed data matrix. The imputation number is appended to each column name.
If include=TRUE then ncol(x$data) additional columns with the original data are appended.
The number .0 is appended to the column names.
"repeated"nrow(x$data) rows and ncol(x$data) * x$m columns.
Columns are ordered such that the first x$m columns correspond to the x$m imputed
versions of the first column in x$data. The imputation number is appended to each column name.
If include=TRUE then ncol(x$data) additional columns with the original data are appended.
The number .0 is appended to the column names.
A data frame with the imputed values filled in. Optionally, the original data are appended.
Stef van Buuren, Karin Groothuis-Oudshoorn, 2009
# 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)