ngreifer / cobalt

Covariate Balance Tables and Plots - An R package for assessing covariate balance
https://ngreifer.github.io/cobalt/
73 stars 12 forks source link

Data not of class 'mids' error when running cobalt::bal.tab with mimids output #50

Closed jbp7 closed 3 years ago

jbp7 commented 3 years ago

I tried to run the following code using the test dataset within the cobalt package:

library("mice"); library("MatchThem")
data("lalonde_mis", package = "cobalt")

#Generate imputed data sets
m <- 10 #number of imputed data sets
imp.out <- mice(lalonde_mis, m = m, print = FALSE) 

#Matching for balance on covariates
mt.out <- matchthem(treat ~ age + educ + married +
                       race + re74 + re75, 
                     datasets = imp.out,
                     approach = "within", 
                     method = "nearest",
                     link = "logit",
                     estimand = "ATT")

bal.tab(mt.out)

However, I get the following error:

Error in imp.complete(mimids$others$source) : 'data' not of class 'mids'

Is there something I'm missing? I tried tracing the error but couldn't exactly find where the check happens for imp.complete.

ngreifer commented 3 years ago

Please update cobalt. This has been fixed in version 4.3.1.