CFA and multipel imputation

39 views
Skip to first unread message

Adam Meddeb

unread,
Jun 17, 2024, 4:38:13 AMJun 17
to lavaan
Hi all,

I got a data frame with n=88 and want to run a CFA using the lavaan package. The model I have specified requires 16 parameters to be estimated.

I am using the mice package to create a list of 5 imputed datasets. 

When reading the lavaan documentation one is advised to use the semtools package to fit a model across several datasets. 

The code I am running looks like this:

# run MI
imp <- mice(data)

# create a list of the datasets generated in mice

imputed_data_list <- lapply(1:5, function(i) complete(imp, i))

# run CFA on each dataset
output <- cfa.mi(model, data = imputed_data_list)

# get pooled results
summary(output)

When I run the last line of code to get the pooled estimates I get the following error: 
"Error in if (categorical.flag) { : argument is of length zero"

How have others run CFA on imputed datasets? I have been consulting the van Buuren & Groothius-Oudshoorn (2011) but not found much on how to handle imputed datasets for CFA. 

Best regards
Adam

Terrence Jorgensen

unread,
Jun 24, 2024, 8:59:13 AM (9 days ago) Jun 24
to lavaan
That bug was resolved months ago in the development versions on GitHub.  Also install the new lavaan.mi package:
 
remotes::install_github("yrosseel/lavaan") 
remotes::install_github("TDJorgensen/lavaan.mi") 
remotes::install_github("simsem/semTools/semTools")

I deprecated runMI() functionality from semTools, and the lavaan.mi package is now updated with many bug-fixes and new features. Read the README and NEWS files closely before proceeding, because other small changes have been made to the user interface.

https://github.com/TDJorgensen/lavaan.mi

https://github.com/TDJorgensen/lavaan.mi/blob/main/NEWS.md

I hope to send this to CRAN by the end of the month or early July.

Terrence D. Jorgensen    (he, him, his)
Assistant Professor, Methods and Statistics
Research Institute for Child Development and Education, the University of Amsterdam
http://www.uva.nl/profile/t.d.jorgensen


Adam Meddeb

unread,
Jul 2, 2024, 7:54:20 AM (yesterday) Jul 2
to lavaan
Thanks Terrence, 

Installing lavaan.mi and using the functions (notably cfa.mi()) provided therein works now fine with my list of imputed datasets :) 
Reply all
Reply to author
Forward
0 new messages