0
$\begingroup$

I need some help with predicting values from my multigroup model. Sadly, the official lavaan tutorial (https://lavaan.ugent.be/tutorial/cov.html) isn't helpful in that regard.
My "problem" is as followed. I have data with a lot of missing values. Therefore I can't calculate a model with the dataframe itself (since lavaan would exclude most cases) and I don't want to use imputation (since the values are missing systematically). My approach was to calculate covariance matrices with the argument use = "pairwise.complete.obs" and continue with these.

I think I used the correct procedure (passing a list with covariance matrices and a list with sample observations to the cfa function) and fitting the model. I can then inspect the model and have a look at the coefficients etc..
However, when it comes to predicting factor scores for individual participants (with a complete dataset), I cannot simply input the raw dataframe in the newdata argument of lavPredict, because lavaan then has no information as to which case belongs to which group.
Is there a way to provide lavaan with the necessary group information? I tried to have a look at the source code and using lavData or lav_data_full might be a solution. However, how that solution looks like, I can't tell...

Thank you in advance!
Daniel

$\endgroup$

1 Answer 1

3
$\begingroup$

the values are missing systematically

You mean planned missing data, using random assignment? That would make the data missing completely at random. Instead of calculating summary data yourself, just pass the data.frame to cfa() and set missing = "pairwise" to use pairwise deletion. Then, lavPredict() will provide factor scores for any rows with complete data.

$\endgroup$
1
  • 1
    $\begingroup$ You Sir are a gentleman and a scholar. No seriously, that is exactly what I was looking for... The pairwise argument is even in the docs. I'm blind... And lavPredict works like a charm. Also, you were right about the duplicate on StackOverflow. I deleted that post. And FYI, what I meant by missing systematically: We have accuracy and reaction time data from an experiment. We don't want to include the reaction times from incorrectly answered items into the model, as they might stem from the participants guessing. $\endgroup$ Jan 24, 2022 at 23:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.