simsem / semTools

Useful tools for structural equation modeling
75 stars 36 forks source link

runMI() using miPackage = "mice" fails #40

Closed lunafazio closed 6 years ago

lunafazio commented 6 years ago

The message:

Error in is.mids(data) : argument "data" is missing, with no default

I've traced it back to this code block:

else if (miPackage[1] == "mice") {
            requireNamespace("mice")
            if (!"package:mice" %in% search()) 
                attachNamespace("mice")
            imputeCall <- c(list(mice::mice, data = data, m = m, 
                diagnostics = FALSE, printFlag = FALSE), miArgs)
            set.seed(seed)
            miceOut <- eval(as.call(imputeCall))
            imputedData <- list()
            for (i in 1:m) {
                imputedData[[i]] <- mice::complete(x = miceOut, 
                  action = i, include = FALSE)
            }
        }

The call to mice::complete should use data = miceOut instead of x = miceOut

TDJorgensen commented 6 years ago

Thanks for tracking it all the way down. I had already fixed this but had not pushed the fix to GitHub. It is now available in the development version:

devtools::install_github("simsem/semTools/semTools")

But I recommend imputing first anyway, so you can take advantage of the diagnostic checks in mice to investigate the quality of your imputations.