simsem / semTools

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

Error: could not find function "is.mids" #54

Closed markseeto closed 5 years ago

markseeto commented 5 years ago

Hello,

I'm using R 3.5.2 and lavaan 0.6-3. With semTools 0.5-1, the following code runs without error:

library(lavaan)
library(semTools)

data.list <- vector("list", 5)

for (j in 1:5) {
  data.list[[j]] <- HolzingerSwineford1939
}

mod <- '
visual =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed =~ x7 + x8 + x9
'

HS.mi <- sem.mi(mod, data = data.list)

But with the development version of semTools (0.5-1.909, installed using devtools::install_github("simsem/semTools/semTools")), the call to sem.mi gives the following error:

Error in is.mids(data) : could not find function "is.mids"

When I installed the development version, there were some warnings like file link 'parTable' in package 'lavaan' does not exist and so has been treated as a topic. I don't know if these are related to the error.

Thanks.

TDJorgensen commented 5 years ago

ironically, I just discovered the same bug and I believe I fixed it :-) Could you try the next version and see if it works?

markseeto commented 5 years ago

Thanks for your reply Terrence. Now I get a different error:

Error in (function (model = NULL, dataList = NULL, dataFunction = NULL,  : 
  lavaan ERROR: (generated) data is not a data.frame (or a matrix)
TDJorgensen commented 5 years ago

Are you passing a mids object to the data= argument? I'm guessing the problem now is that you have mice installed, but you were passing a list of data.frames (not a mids object, which should be a perfectly valid workflow). I have made the check more nuanced, should work now. But please restart R before and after installing version 0.5-1.911

markseeto commented 5 years ago

Thanks Terrence, with version 0.5-1.911 there is no error. I wasn't passing a mids object. I have mice installed but not loaded.

Thanks.