
Last chance! 50% off unlimited learning
Sale ends in
mids
-objects into a single data frame
by computing the mean or selecting the most likely imputed value.merge_imputations(dat, imp, ori = NULL)
mice
-function call.mids
-object with the imputed data frames
from dat
.ori
is specified, the imputed variables are
appended to this data frame; else, a new data frame with the imputed
variables is returned.ori
with
appended imputed variables, if ori
was specified.imp
must be a mids
-object, which is returned by the
mice
-function of the mice-package. merge_imputations
than
creates a data frame for each imputed variable, by combining all
imputations (as returned by the complete
-function)
of each variable, and computing the row means of this data frame.
The mean value is then rounded for integer values (and not for numerical
values with fractional part), which corresponds to the most frequent
imputed value for a missing value. The original variable with missings
is then copied and missing values are replaced by the most frequent imputed
value.library(mice)
imp <- mice(nhanes)
# return data frame with imputed variables
merge_imputations(nhanes, imp)
# append imputed variables to original data frame
merge_imputations(nhanes, imp, nhanes)
Run the code above in your browser using DataLab