I’m working on a project using R and the lavaan package for Confirmatory Factor Analysis (CFA). I’ve successfully fit a CFA model and can see the standardized loadings in the ‘Std.all’ column of the lavaan output. However, I’m struggling to plot these standardized loadings instead of the estimated ones.
I’ve tried using lavaanPlot, but it seems to default to the ‘Estimate’ column values. I’ve experimented with different options, including the ‘edge_options’ argument, but haven’t found a way to specify the use of standardized loadings.
Here’s a simplified version of what I’m working with:
library(lavaan)
library(lavaanPlot)
# Simple CFA model
model <- 'factor =~ item1 + item2 + item3'
fit <- cfa(model, data = mydata)
# This plots estimated loadings, not standardized
lavaanPlot(model = fit, coefs = TRUE)
Is there a way to make lavaanPlot use the ‘Std.all’ values? Or is there another package or method you’d recommend for visualizing standardized CFA loadings? Any help would be greatly appreciated!
This should give you a nice tree diagram with the standardized loadings. The ‘std’ argument tells it to use standardized coefficients.
But here’s a thought - why do you prefer the standardized loadings over the estimated ones? I’m curious about your specific use case. Maybe there’s an even better way to visualize what you’re after?
Also, have you considered creating a custom plot using ggplot2? It might take a bit more code, but you’d have total control over the visualization. What do you think about that idea?
Let me know how it goes or if you need any more help! Always fun to dive into these R visualization challenges.
I’ve encountered this issue before when working with lavaan and CFA visualizations. While lavaanPlot is useful, it does have limitations when it comes to displaying standardized loadings.
One alternative approach you might consider is using the semPlot package, which offers more flexibility in this regard. You can use the following code to generate a plot with standardized loadings:
This should create a tree diagram showing the standardized loadings from your CFA model. The ‘what = “std”’ argument specifically tells semPlot to use the standardized coefficients.
If you need more customization options, you might want to explore creating a plot from scratch using ggplot2. This would require extracting the standardized loadings from your fit object and then building the visualization manually, but it would give you complete control over the appearance and layout.