I’m working on a CFA model and I’ve got some missing data. I want to figure out how to get factor scores and confidence intervals. Here’s what I’ve done so far:
I made a dataset with 500 rows. It has stuff like ID, state, school, gender, and five items. Some of the item values are missing on purpose.
Then I set up a CFA model like this:
model <- '
Satisfaction =~ item1 + item2 + item3 + item4 + item5
Satisfaction ~~ 1*Satisfaction
Satisfaction ~ 0
'
fit <- cfa(model, data = my_data, estimator = 'MLR', std.lv = FALSE)
I can get a summary of the fit, but I’m stuck on how to get factor scores and their confidence intervals with the NAs in my data. Any ideas? I’m using the lavaan package in R if that helps.
For calculating factor scores and confidence intervals with missing data in your CFA model, you’re on the right track using the MLR estimator. Here’s what you can do next:
Get factor scores using lavPredict():
factor_scores ← lavPredict(fit, type = ‘lv’)
This handles missing data automatically.
For confidence intervals, you’ll need to use bootstrapping. Here’s a basic approach:
Create a bootstrap function that fits your model and calculates factor scores. Use the boot package to run the bootstrap. Then, calculate confidence intervals from the bootstrap results.
Something like:
bootstrap_func ← function(data, indices) {
boot_fit ← cfa(model, data[indices,], estimator=‘MLR’, std.lv=FALSE)
lavPredict(boot_fit, type=‘lv’)
}
boot_results ← boot(data=my_data, statistic=bootstrap_func, R=1000)
Then use boot.ci() to get confidence intervals.
This approach should give you factor scores and CIs that account for your missing data.
hey mia! for factor scores, try lavPredict(fit, type=‘lv’). it handles missing data pretty well.
for confidence intervals, you might wanna look into bootstrapping. it’s a bit more work but can give you what you need. you’d make a function to fit your model and get scores, then use the boot package to run it lots of times.
lemme know if you need more help with the bootstrapping part!
Hey there Mia_79Dance! 
Your CFA setup looks solid so far. Getting factor scores and confidence intervals with missing data can be a bit tricky, but I think I can help point you in the right direction.
For factor scores, have you tried using lavPredict()? It’s pretty nifty with missing data:
factor_scores ← lavPredict(fit, type = ‘lv’)
That should give you the factor scores, handling those pesky NAs.
Now, for confidence intervals, things get a bit more interesting. Lavaan doesn’t give us CIs for factor scores out of the box, so we’ll need to get creative. Have you considered bootstrapping? It’s like giving your data a fun little workout! 
Here’s a quick idea:
- Make a function that fits your model and gets factor scores
- Use the boot package to run this function a bunch of times
- Use the results to calculate CIs
It might look something like this:
library(boot)
boot_func <- function(data, indices) {
boot_fit <- cfa(model, data[indices,], estimator='MLR', std.lv=FALSE)
lavPredict(boot_fit, type='lv')
}
boot_results <- boot(data=my_data, statistic=boot_func, R=1000)
Then you can use boot.ci() to get those sweet, sweet confidence intervals.
What do you think? Have you tried anything like this before? I’m really curious to hear how it goes if you give it a shot!