simongrund1/mitml

Cannot change to mids object.

Closed this issue · 2 comments

I created a jomo imputation and then tried the following steps to convert it to a mids object using these resources.

https://rdrr.io/cran/mitml/man/mitmlComplete.html
https://rdrr.io/cran/mitml/man/mitml.list2mids.html

implist <- mitmlComplete(jomo_imputation)

This gives the error "Error in order(attr(x$data, "sort")) : argument 1 is not a vector"

mids_data <- mitml::mitml.list2mids(implist, data = original_data)

This gives the error "Error in rbind(deparse.level, ...) : numbers of columns of arguments do not match" when fill = TRUE.

Any resources with instructions? Thank you.

I can't reproduce this, but the error message looks like you created jomo_imputation with jomo() (from the "jomo" package) and not jomoImpute() (from "mitml"). The mitmlComplete() function creates a list of imputed data sets from imputations created with "mitml". For other imputation packages such as "jomo" and "mice", there are other functions for creating these lists. For example, for "jomo", you should use jomo2mitml.list().

# packages and data
library(mitml)
library(jomo)
library(mice)

dat <- studentratings[, c("SES", "ReadAchiev")]

# Example 1: with "mitml"
imp1 <- mitml::jomoImpute(data = dat, formula = SES + ReadAchiev ~ 1)
implist1 <- mitmlComplete(imp1)
mids1 <- mitml.list2mids(implist1, data = dat)

# Example 2: with "jomo"
imp2 <- jomo::jomo(dat)
implist2 <- jomo2mitml.list(imp2)
mids2 <- mitml.list2mids(implist2, data = dat, fill = TRUE)

No news for a week, so I will assume this was solved.