Error Message running cfa.mi (semTools) after specifing Imputation-Modell in mice

28 views
Skip to first unread message

Sebastian85

unread,
May 21, 2019, 4:52:15 PM5/21/19
to lavaan
Hello,

I'm conducting a cfa to test a six factor structure of aquestionnaire, four Items are loading on each factor. The Items shows a five-point likert scale, I consider them as ordered. To handle the Missings I'm conducting a Multiple Imputation with the R-Package mice. The following Codes dosen't work: 

#Specifing Imputation-Model 

eltern.imp.pmm<-mice(Eltern_ek, pri=F, m=1, maxit = 0)
eltern.imp.pmm$predictorMatrix
pred.eltern.pmm<-eltern.imp.pmm$predictorMatrix
pred.eltern.pmm[,"id"]<-0
pred.eltern.pmm
meth.eltern.pmm<-eltern.imp.pmm$meth
meth.eltern.pmm["sex.x"]<-""
meth.eltern.pmm

Eltern.imp.pmm<-mice(Eltern_ek, method=meth.eltern.pmm, pred=pred.eltern.pmm, m=5, maxit=5, pri=F, seed= 12345)

#Running cfa

imps.mice<-list()
for(i in 1:5) imps.mice[[i]]<-complete(Eltern.imp.pmm, action=i)

Model<-'F1=~Item11+Item12+Item13+Item14
F2=~Item21+Item22+Item32+Item42
F3~Item31+Item32+Item33+Item34
F4=~ Item41+Item42+Item43+Item44
F5=~ Item51+Item52+Item53+Item54
F6=~ Item61+Item62+Item63+Item64'

cfa.fit<-cfa.mi(, data=imps.mice, ordered=names(Eltern_ek),estimator = "WLSMV", mimic="MPlus")

I get the following error: 
Error in colMeans(do.call(rbind, coefList)) : 
  'x' must be an array of at least two dimensions

Without Specifing the Imputation-Model, the Code works fine. It would be great if anyone has an idea to solve the problem. Thanks!

Best Regards
Sebastian 

balal izanloo

unread,
May 21, 2019, 7:29:29 PM5/21/19
to lav...@googlegroups.com
Hi
First of all check your syntax for the comma befor 'data'. I think something is wrong.
cfa.fit<-cfa.mi(, data=imps.mice, 


--
You received this message because you are subscribed to the Google Groups "lavaan" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lavaan+un...@googlegroups.com.
To post to this group, send email to lav...@googlegroups.com.
Visit this group at https://groups.google.com/group/lavaan.
To view this discussion on the web visit https://groups.google.com/d/msgid/lavaan/b22045e9-a117-4861-9b2c-c0748add0865%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sebastian85

unread,
May 22, 2019, 1:40:25 AM5/22/19
to lavaan
Dear balal,

thank you. You're right, the synthax isn't correct (Correct cfa.mi-synthax see below). Unfortunately, this not causes the error. 

#Specifying Imputation-Model 

eltern.imp.pmm<-mice(Eltern_ek, pri=F, m=1, maxit = 0)
eltern.imp.pmm$predictorMatrix
pred.eltern.pmm<-eltern.imp.pmm$predictorMatrix
pred.eltern.pmm[,"id"]<-0
pred.eltern.pmm
meth.eltern.pmm<-eltern.imp.pmm$meth
meth.eltern.pmm["sex.x"]<-" "
meth.eltern.pmm

Eltern.imp.pmm<-mice(Eltern_ek, method=meth.eltern.pmm, pred=pred.eltern.pmm, m=5, maxit=5, pri=F, seed= 12345)

#Running cfa

imps.mice<-list()
for(i in 1:5) imps.mice[[i]]<-complete(Eltern.imp.pmm, action=i)

Model<-'F1=~Item11+Item12+Item13+Item14
F2=~ Item21+Item22+Item32+Item42
F3=~ Item31+Item32+Item33+Item34
F4=~ Item41+Item42+Item43+Item44
F5=~ Item51+Item52+Item53+Item54
F6=~ Item61+Item62+Item63+Item64'

cfa.fit<-cfa.mi(Model, data=imps.mice, ordered=names(Eltern_ek),estimator = "WLSMV", mimic="MPlus")

Best Regards
Sebastian 

I (still) get the following error: 
Error in colMeans(do.call(rbind, coefList)) : 
  'x' must be an array of at least two dimensions

Terrence Jorgensen

unread,
May 22, 2019, 2:48:51 AM5/22/19
to lavaan
I don't notice anything wrong with the syntax.  Make sure you have the latest software install, in case this is a bug that was already resolved.

install.packages("lavaan", repos = "http://www.da.ugent.be", type = "source")
devtools
::install_github("simsem/semTools/semTools")

Restart R before running your script again.  If the error still occurs, I would need your data and minimal script required to reproduce the error, in order to track it down.

Terrence D. Jorgensen
Assistant Professor, Methods and Statistics
Research Institute for Child Development and Education, the University of Amsterdam

Reply all
Reply to author
Forward
0 new messages