Learn R Programming

sjmisc (version 2.3.0)

merge_imputations: Merges multiple imputed data frames into a single data frame

Description

This function merges multiple imputed data frames from mids-objects into a single data frame by computing the mean or selecting the most likely imputed value.

Usage

merge_imputations(dat, imp, ori = NULL)

Arguments

dat
The data frame that was imputed and used as argument in the mice-function call.
imp
The mids-object with the imputed data frames from dat.
ori
Optional, if ori is specified, the imputed variables are appended to this data frame; else, a new data frame with the imputed variables is returned.

Value

A data frame with imputed variables; or ori with appended imputed variables, if ori was specified.

Details

This method merges multiple imputations of variables into a single variable by computing the (rounded) mean of all imputed values of missing values. By this, each missing value is replaced by those values that have been imputed the most times. 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.

References

Burns RA, Butterworth P, Kiely KM, Bielak AAM, Luszcz MA, Mitchell P, et al. 2011. Multiple imputation was an efficient method for harmonizing the Mini-Mental State Examination with missing item-level data. Journal of Clinical Epidemiology;64:787–93 \Sexpr[results=rd,stage=build]{tools:::Rd_expr_doi("#1")}10.1016/j.jclinepi.2010.10.011http://doi.org/10.1016/j.jclinepi.2010.10.011doi:\ifelse{latex}{\out{~}}{ }latex~ 10.1016/j.jclinepi.2010.10.011

Examples

Run this code
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