I’m working on a Confirmatory Factor Analysis (CFA) project and I’ve run into a snag. My dataset has some missing values (NAs) and I’m not sure how to handle this when calculating factor scores and their confidence intervals. Here’s what I’ve done so far:
I created a sample dataset with 500 observations and 5 items. Each item has some NAs randomly inserted. Then I set up a simple CFA model for a ‘Satisfaction’ factor using all 5 items.
# Create sample data
n = 500
df = data.frame(
ID = 1:n,
item1 = sample(c(NA, runif(n, 0, 1)), n, replace = TRUE),
item2 = sample(c(NA, runif(n, 0, 1)), n, replace = TRUE),
item3 = sample(c(NA, runif(n, 0, 1)), n, replace = TRUE),
item4 = sample(c(NA, runif(n, 0, 1)), n, replace = TRUE),
item5 = sample(c(NA, runif(n, 0, 1)), n, replace = TRUE)
)
# CFA model
model = 'Satisfaction =~ item1 + item2 + item3 + item4 + item5'
# Fit model
library(lavaan)
fit = cfa(model, data = df, estimator = 'MLR')
Now, how do I calculate factor scores and their confidence intervals with this NA-containing data? Any help would be greatly appreciated!