Hello everyone, I’m running a confirmatory factor analysis in R using the lavaan package and have already obtained the factor loadings (for example, with something like inspect(myModel, what = “est”)$lambda). However, I am now looking for a way to extract the error variances associated with each indicator in my model. I would appreciate any guidance or alternative approaches for accessing these error parameters. Below is a modified sample code snippet demonstrating my analysis:
library(lavaan)
model_spec <- '
factorA =~ var1 + var2 + var3
factorB =~ var4 + var5 + var6
factorC =~ var7 + var8 + var9
'
model_fit <- cfa(model_spec, data = sampleData)
summary(model_fit, fit.measures = TRUE)
Thank you in advance for your help!
hey, try inspect(model_fit, “est”)$theta; this should give u the error variances. i’ve seen some peeps use parameterTable(model_fit) too for a more detailed look. hope this helps!
In my experiences, I’ve found it useful to extract the entire parameter table from lavaan and then filter out measurement error variances based on the parameter identifiers. Typically, I retrieve the parameter table using parameterTable(model_fit) or by accessing model_fit@ParTable. I then isolate rows where the operator is ‘~~’ and the lhs equals the rhs. This approach, though slightly more manual, provides clarity and flexibility, especially when dealing with more complex or multi-group models. It’s been a robust method in my analyses.
Hey Nate, I wanted to share another approach that has worked for me in extracting error variances. Once you run your model, you can use the parameterEstimates() function. This returns a data frame with all the parameter estimates, and you can then filter down to just the error variances. For example, looking for rows where the operator is ‘~~’ and the variable names on both sides match (like var1 ~~ var1) usually points to the measurement error. I find this method really flexible since you can also grab other useful details like standard errors and significance levels if needed. Have you ever used parameterEstimates() in this way before? What filters or additional info do you typically pull out from your CFA results? Would be great to hear your thoughts or any tips you’ve picked up along the way! 