I’m working on a confirmatory factor analysis (CFA) for my survey using the lavaan package in R and need help obtaining a correlation matrix that shows significance levels, or p-values, for each factor. I tried using cov2cor(inspect(fit, what = "est")$psi), but that only returns the matrix.
Here’s a sample model example:
model_cfa <- '
cognitive =~ q1 + q2 + q3
emotional =~ q4 + q5 + q6
behavioral =~ q7 + q8 + q9
'
results <- cfa(model_cfa, data = my_survey_data,
auto.var = TRUE, auto.fix.first = TRUE,
auto.cov.lv.x = TRUE)
Does anyone have suggestions on how to retrieve both the correlation values and their corresponding p-values in one command?
I’ve encountered this issue before in my research and found a method that works well with lavaan. I first fit the CFA model as usual and then retrieved the factor correlation matrix via lavInspect(results, “est”)$psi. After that, I developed a custom function that tests each correlation against a null model with that correlation fixed to zero, using lavTestLRT() to obtain the p-value. Finally, I combined the extracted p-values with the correlation estimates into a single data frame. This approach is a bit involved, but it gives precise p-values for each factor correlation. Also, make sure to adjust for multiple comparisons when testing many correlations.
hey there, i’ve been using lavaan for a while and ran into the same issue. have you tried the parameterEstimates() function? it gives you both estimates and p-values for all model parameters, including factor correlations. something like parameterEstimates(results, standardized=TRUE) might work for ya. hope that helps!
Hey Nate_45Guitar! 
I totally get your struggle with lavaan. It’s such a powerful tool, but sometimes getting exactly what you need can be tricky.
Have you considered using the modindices() function? It might give you some extra insights beyond just the correlations and p-values. Plus, it could help you spot any potential improvements for your model fit.
Also, I’m curious - what kind of survey are you working on? The cognitive-emotional-behavioral structure sounds intriguing. Are you looking at any specific psychological construct?
Oh, and a random thought - have you ever tried visualizing your factor correlations? Sometimes a good plot can really bring the data to life. Any favorite R packages for that?
Keep us posted on how it goes! 