I am running some multi-group confirmatory factor analyses (CFA) in lavaan
in R
after multiple imputation.
First, I created a list called Plav
to store 5 imputed datasets:
library(lavaan)
library(lavaan.survey)
library(mitools)
library(semTools)
a <- imputationList(Plav) ##Tell R these are plausible values
Survey <- svydesign(ids = ~1, weights = ~wt, data = a) # set the weight
Subsequently, I conducted a multi-group CFA:
# Model without population corrections
fit <- cfa(model, data=Plav[[1]], estimator = 'MLR', missing = 'default', group = 'gender',group.equal = c("loadings"))
# Model with population corrections
fitSurvey <- lavaan.survey(lavaan.fit = fit, survey.design = Survey)
The following error was returned:
Error in FUN(X[[1L]], ...) :
dims [product 1936] do not match the length of object [0]
When I remove the grouping variable and conduct an analysis on the whole sample, no error is returned.
Can anybody explain why this error is returned?