1
$\begingroup$

So I am new to R and new to MI as well. Reading through "Flexible Imputation of Missing Data" and slowly becoming acquainted.

I was going through a sample run of my data, worked through most of the necessary steps outlined in book and "mice: Multivariate Imputation by Chained Equations in R" paper...but I can't come up with a code that lets you take all the 50 datasets and just get one output data with imputed/oroginal values. Is this even possible with MICE or MI in general? I tried Amelia and Zelig too and I get confused at this step. I get the point that one should pool through all the datasets but going through all 50 in this sample run would be too exhausting.

Since I am still new, I apologize for missing something and would appreciate an example or code that lets me pool one dataset to model with through an index in another software.

$\endgroup$
  • $\begingroup$ have a look at mice::complete() $\endgroup$ – timbp Mar 21 '16 at 21:55
  • $\begingroup$ Questions about how to use R are off topic here (see our help center). But I think the issue here is a statistical misunderstanding: you don't put all M imputed datasets into 1 dataset. $\endgroup$ – gung Mar 21 '16 at 21:57
  • $\begingroup$ Oh thanks, sorry being off topic. I will rephrase the question. So in this case if I should choose smaller m, like m=5 and run the model for all 5 datasets? I did look at complete() but it appears to just pull out the all the datasets not compile them into one distinct dataset from all others. $\endgroup$ – Sasha Mar 21 '16 at 22:35
  • $\begingroup$ Yes, you repeat your analysis with all five data sets. So for M=50 imputed data sets, you obtain 50 sets of results. These results (not the data sets!) are then pooled into a final set of estimates and standard errors. Procedures for running analyses on multiply imputed data sets and pooling their results are available in a number of R packages (e.g., mitools, mitml). $\endgroup$ – SimonG Mar 22 '16 at 10:41
  • $\begingroup$ Yes the R packages give you all those options as well as running the models right there. The thing is I need to extract the datasets and run them through another software, then once I get the results would I have to pool them altogether? Basically, I have m=5 imputed datasets. I impute them, then I take the extracted data to another software and run the model with the data. Then I will have to do statistical analysis for all 5 results and pool together again? $\endgroup$ – Sasha Mar 24 '16 at 17:24
1
$\begingroup$

It seems that you want to stack the imputed datasets. As noted by those who have commented previously, this is not the best way to analyse the data (point estimates tend to be accurate, but the variability accounted for by the imputation process is no longer present and error will be reduced). Nevertheless, stacking the data is achieved by using the complete function in the mice package. Once stacked, the data can be exported easily to other software programs.

# Impute the data using the default options
imp <- mice(df)

# Check convergence
plot(imp)

# Stack imputed data into one LONG dataset (generates two new variables indicating id and imputation number); raw (unimputed) data are appended (inc = TRUE)
com <- complete(imp, "long", inc = TRUE)

# Obtain first imputed dataset
com <- complete(imp)
com <- complete(imp, 1)

# Obtain second imputed dataset
com <- complete(imp, 2)

It is also possible to export the mids object (imp) directly to SPSS (if that is your other software) using the mids2spss function in mice.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.