Please find a related question and response from Mauricio:
Hi Mauricio,
I have estimated a single factor CFA model in Lavaan, and I derived factor scores using LavPredict. My dataframe, however, contains missing data, and it does not appear that LavPredict is able to calculate SEs for each estimated factor score when observations are not complete. I attempted to use your suggested blavaan code below, setting save.lvs=T, but I receive a similar error:
blavaan ERROR: lvs cannot currently be saved when data are missing.
Do you have any suggestions to work around this limitation and calculate SEs of the factor scores?
Thanks,
Adam
Adam
This is an issue with the new default Stan parameterization. If you want to extract factor scores you can use the old Stan method (target="stanclassic"), which the only disadvantage is that is slower. With missing data the posterior log-likelihhod will be slower, either way. I am showing an example at the end
Now, in general, it is not recommended to use factor scores as this does adds factor inderterminancy issues. Some, can be solve by treating factor scores from posterior draws as multiple imputations to account for factor indeterminancy and sample variability. This can be done with the function plausibleValues from semTools, which does work with blavaan objects
Please continue these questions in the blavaan google group forum. This way more people can help, and it stays there so other users can search for similar issues
Hope this helps
library(blavaan)
future::plan("multiprocess")
library(simsem)
## The famous Holzinger and Swineford (1939) example
HS.model <- ' visual =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed =~ x7 + x8 + x9
'
dat_test <- imposeMissing(HolzingerSwineford1939,
pmMCAR=.2)
summary(dat_test)
fit <- bcfa(HS.model,
std.lv=T,
save.lvs=T, target="stanclassic",
data = dat_test)
summary(fit, standardized=T)
lvs <- blavInspect(fit, "lvmeans")
head(lvs)