How can I combine all dataframes in an amelia object into a single dataframe?

Viewed 77

I made an amelia object, consisting of 5 dataframes generated with multiple imputation done on my provided dataset with missing values. I want to combine all of these dataframes into a single dataframe that I can then use in all subsequent analyses in my program, but I'm struggling to find out how to do this. Do I just use the 5th dataframe in the object, or is there some series of steps I need to do to get all the dataframes averaged and put together?

I keep seeing stuff about mi.meld but I can't find something that clearly tells me what the arguments should be and in what format they need to be and why (sorry, I'm very new to this).

Thank you for your help :)

1 Answers

Amelia can be a little tricky to combine with your workflow but you can do what you want easily using R's helpful list management and iteration functions! What you need to do, briefly, is taking your imputations from amelia_object$imputations (amelia_object being an object constructed by the amelia() function), then combining them all into a single data frame with a simple bind_rows() function and grouping and nesting the different imputations into different rows. Then, you run any model that you want over all different imputations (using functions for iteration such as those from the purrr package). Amelia's mi.meld function expects a dataframe of quantities obtained by running your model on different imputations (such as sets of coefficients from a linear model) and also a dataframe of standard errors that correspond to these quantities. I think this helpful guide and this one will guide you through the whole process! If the problem isn't resolved and you need to do something more sophisticated, feel free to share more details about your specific problem and reproducible code!

Related