Fit the model with estimator = "MLR" and cluster = "ID".
Extract these fit measures: rmsea.robust, cfi.robust, tli.robust, srmr_within, srmr_between.
Interpret what it would mean if srmr_between were much worse than srmr_within.
Show code
# Write your code here
Exercise 3 — Compare single-level vs multilevel thinking
A common (bad) habit is to ignore clustering and just fit a single-level CFA.
Your task
Fit a single-level CFA to the same ordinal indicators (no cluster=).
Compare the story you would tell about fit vs the two-level fit.
(Conceptual) What is the risk of relying on the single-level fit here?
Show code
# Write your code here
Exercise 4 — Level-specific parameters (loadings)
Your task
Extract standardized loadings at Level 1 and Level 2.
Do you see stronger loadings at Level 2? Why could that happen?
Show code
# Write your code here
Exercise 5 — Stress test: induce Level-2 misfit
We now create a dataset where between-level residual correlations exist (not captured by the factor).
Show code
# Create a new dataset ESMdata2 with extra between correlations among d1 and d2eta_b2 <-rnorm(n_id, 0, 0.7)eta_b2_long <-rep(eta_b2, each = n_rep)eta_w2 <-rnorm(N, 0, 1.0)# Add a shared between-only disturbance u_b to items 1 and 2u_b <-rnorm(n_id, 0, 0.6)u_b_long <-rep(u_b, each = n_rep)y2_cont <-sapply(seq_along(lambda), function(j) { base <- lambda[j] * (eta_b2_long + eta_w2) +rnorm(N, 0, eps_sd[j])if (j %in%c(1,2)) base <- base + u_b_long base})ESMdata2 <-data.frame(ID = ID,d1 =cut_likert(y2_cont[,1]),d2 =cut_likert(y2_cont[,2]),d3 =cut_likert(y2_cont[,3]),d4 =cut_likert(y2_cont[,4]))
Your task
Fit the same two-level CFA on ESMdata2.
Compare srmr_within and srmr_between to the original dataset.
Propose one model modification at Level 2 that could improve srmr_between.