1

When using the lavaan package in R, I fit a CFA model:

# Load libraries:
library(dplyr)
library(lavaan)

# Create variables:
var1 <- 
  rnorm(10, 5, 1)

var2 <- 
  rnorm(10, 5, 1)

var3 <- 
  rnorm(10, 5, 1)

# Create dataframe:
df <-
  tibble(var1, var2, var3)

# Define CFA model:
latent_var <-
  "latent_var =~ var1 + var2 + var3"

# Fit CFA model, ignoring warnings:
cfa_mod <-
  cfa(latent_var, df)

# Summarise, specifying standardised factor loadings:
summary(cfa_mod, standardized = TRUE)

However, when I want to plot (I've been using lavaanPlot), there seems to be no way to specify that I want the standardised loadings from the 'Std.all' column rather than the estimated loadings from the 'Estimate' column:

# Load libraries:
library(lavaanPlot)

# Plot model, specifying coefficient labels:
lavaanPlot(model = cfa_mod, coefs = TRUE)

I've played about with the 'edge_options =' argument, hoping to find some way of specifying standardised loadings, but no success (the documentation seems to suggest that this argument is aesthetic, for setting colours etc.). How can I plot the 'Std.all' column from the lavaan output instead of the 'Estimate' column, using lavaanPlot (or any other plotting package)?

dalexco
  • 31
  • 5
  • 1
    It is an easy option in the `semPlot` package: http://sachaepskamp.com/semPlot/examples#Lavaan – Terrence Jun 28 '23 at 10:21
  • Thanks very much. Sadly, I'm unable to install semPlot due to an inability to install a package called OpenMx. The issue is discussed at length here (https://github.com/OpenMx/OpenMx/issues/238), here (https://openmx.ssri.psu.edu/node/4239), and here (https://stackoverflow.com/questions/50014226/cannot-install-package-openmx-in-r), but sadly these fixes are beyond my skills as a programmer. +1, though, and hopefully anyone else coming here will be able to install and use semPlot to plot their standardised factor loadings! – dalexco Jun 28 '23 at 12:57

1 Answers1

2

I've been using lavaanPlot, there seems to be no way to specify that I want the standardised loadings from the Std.all column

There is, but it is not showing on the ?lavaanPlot help page because the option is passed via ... to the buildPaths() function. If you look up the latter's help page, you will find the stand=TRUE option will plot standardized paths. This is also shown in the package's vignette("Intro_to_lavaanPlot", package = "lavaanPlot")

https://cran.r-project.org/web/packages/lavaanPlot/vignettes/Intro_to_lavaanPlot.html

Terrence
  • 780
  • 4
  • 7
  • Thanks @Terrence. Solved my problem and good advice generally for a new(ish) R user that not all arguments are contained in the help page – dalexco Jul 02 '23 at 08:18