'predict() and resid() for lavaan.survey

I want to conduct CFA with survey design weight in R.

An easy option seems to be using lavaan.survey package. However, from lavaan object created by lavaan.survey(), information such as residuals by resid() or factor scores by predict() cannot be extracted, which are available in the one created by normal lavaan().

Does anyone know any way to extract such information also from lavaan.survey()?

For your information, error message for resid() is "Error in cov(data, use = "pairwise") : supply both 'x' and 'y' or a matrix-like 'x'"

and for predict() "Error in lavPredict(object = object, newdata = newdata, type = "lv", method = "EBM", : lavaan ERROR: sample statistics were used for fitting and newdata is empty"

Not restricted to lavaan, any other option which enables CFA with design weight including information above is also welcome.

Thanks in advance.



Solution 1:[1]

It is an old question, but it has not received any answer yet. For me, it worked to simply indicate what my original data frame is under the newdata option.

lavaan.fit <- sem(model, data = df)
survey.fit <- lavaan.survey(lavaan.fit, survey.design = my.dsgn)
lavPredict(survey.fit, newdata = df)

According to this thread, this should not affect the estimated factor scores.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Pablo V.