Extracting individual item error variances in lavaan confirmatory factor analysis

I’m working on a confirmatory factor analysis using the lavaan package in R. I’ve set up a model with three factors: visual, textual, and speed. Each factor has three indicators. Here’s a simplified version of my code:

library(lavaan)

my_model <- '
  factor1 =~ indicator1 + indicator2 + indicator3
  factor2 =~ indicator4 + indicator5 + indicator6
  factor3 =~ indicator7 + indicator8 + indicator9
'

model_fit <- cfa(my_model, data = my_dataset)
summary(model_fit)

I know how to get the factor loadings, but I’m stuck on how to extract the error variances for each indicator. Is there a specific function or method in lavaan to get these values? Any help would be great!

Hey there, DancingButterfly! :wave:

I totally get your confusion about extracting those pesky error variances. Lavaan can be a bit tricky sometimes, right?

Have you tried using the parameterEstimates() function? It’s a real lifesaver when you need to dig into the nitty-gritty details of your CFA model. Something like this might do the trick:

pe <- parameterEstimates(model_fit)
error_variances <- pe[pe$op == '~~' & pe$lhs == pe$rhs, ]

This should give you a nice table with all the error variances for your indicators. Pretty neat, huh?

But I’m curious - what made you choose these specific indicators for your factors? And how’s the model fit looking so far? Sometimes tweaking the indicators can make a big difference in the overall fit.

Oh, and just a thought - have you considered running a reliability analysis on your factors? It could give you some extra insights into how well your indicators are working together.

Let me know how it goes! Always happy to brainstorm more if you hit any other snags. CFA can be a real brain-teaser sometimes, but that’s what makes it fun, right? :smile:

yo dancingbutterfly! ive used lavaan before and for error variances, try inspectng the residuals() function output. it gives you a matrix with error variances on the diagonal. something like:

error_vars ← diag(residuals(model_fit)$cov)

hope that helps! lemme kno if u need more info