Skip to contents

Make a quick and decent-looking lavaanPlot.

Usage

nice_lavaanPlot(
  model,
  node_options = list(shape = "box", fontname = "Helvetica"),
  edge_options = list(color = "grey"),
  coefs = TRUE,
  stand = TRUE,
  covs = FALSE,
  stars = list("regress"),
  sig = 0.05,
  graph_options = list(rankdir = "LR"),
  ...
)

Arguments

model

SEM or CFA model to plot.

node_options

Shape and font name.

edge_options

Colour of edges.

coefs

Logical, whether to plot coefficients.

stand

Logical, whether to standardized coefficients.

covs

Logical, whether to plot covariances

stars

Logical, whether to plot significance stars.

sig

Significance threshold.

graph_options

Read from left to right, rather than from top to bottom.

...

Arguments to be passed to function lavaanPlot::lavaanPlot.

Value

A lavaanPlot, of classes c("grViz", "htmlwidget"), representing the specified lavaan model.

Illustrations

Examples

(latent <- list(visual = paste0("x", 1:3),
                textual = paste0("x", 4:6),
                speed = paste0("x", 7:9)))
#> $visual
#> [1] "x1" "x2" "x3"
#> 
#> $textual
#> [1] "x4" "x5" "x6"
#> 
#> $speed
#> [1] "x7" "x8" "x9"
#> 

HS.model <- write_lavaan(latent = latent)
cat(HS.model)
#> ##################################################
#> # [-----Latent variables (measurement model)-----]
#> 
#> visual =~ x1 + x2 + x3
#> textual =~ x4 + x5 + x6
#> speed =~ x7 + x8 + x9
#> 

library(lavaan)
fit <- cfa(HS.model, HolzingerSwineford1939)
nice_lavaanPlot(fit)