I have a data set of twins, which means that my data has dependent observations. Each family is a cluster that has two observations inside (or less in some cases with missing values). I want to do a CFA. Now, because my observed variables have only 5 levels and are not normally distributed, I use the 'DWLS' estimator and not the 'ML' or 'MLM' estimators, as recommended in Mindrila,D. (2010) and in other questions posted on cross-validated platform...
I tried to do a CFA with the lavaan and lavaan.survey packages. My problem though, is that whenever I specify that the estimator should be 'DWLS' or 'WLS', I get an error message that I don't understand. When I use the 'ML' estimator I don't get any errors, but the fit measures, as expected, are not so satisfying...
This is my syntax:
fit <- cfa(model, data=D, std.lv=TRUE, estimator="DWLS") design <- svydesign(id=~ifam, data=D) fit_complex <- lavaan.survey (fit, survey.design = design,estimator="DWLS")
This is the error I get:
"Error in crossprod(Delta[[g]], lavsamplestats@WLS.VD[[g]] * diff) : non-conformable arguments In addition: Warning messages: 1: In diff * diff * WLS.VD : longer object length is not a multiple of shorter object length 2: In lavsamplestats@WLS.VD[[g]] * diff : longer object length is not a multiple of shorter object length"
According to the package manual it should be possible to use 'DWLS' estimator. Can anyone tell me what is it that I am doing wrong?
Thank you very much in advance