Beginning with v0.7, lavaan can now fit multilevel models with random slopes (aside from that, lavaan can now estimate multilevel categorical CFA models too!). 1. Make a toy dataset Here’s an example dataset with a random slope:
Sep 12, 2026
Including random slopes (when warranted) in multilevel models is necessary to avoid making Type I errors as a result of underestimated standard errors. We typically investigate the presence of random slopes (RS) by using a likelihood ratio test and comparing two competing models. Often, random slopes are included when we have cross level interactions. If a random intercept (RI) model is used when a random slope model is warranted, the regression coefficients will be the same though the standard errors will be incorrect.
Jan 6, 2026