plot_latent_network_diagram: Plot a latent network diagram (SEM path diagram)

View source: R/plot_latent_network_diagram.R

plot_latent_network_diagramR Documentation

Plot a latent network diagram (SEM path diagram)

Description

Plot a latent network diagram (SEM path diagram)

Usage

plot_latent_network_diagram(
  model_object,
  filename,
  output_path = NULL,
  width = 9.5,
  height = 6.5,
  resolution = 1500,
  node_labels = NULL,
  color_scheme = NULL,
  color_palette = "auto",
  plot_settings = NULL,
  device_settings = NULL,
  edge_settings = NULL,
  save_message = TRUE,
  show_manifest = TRUE
)

Arguments

model_object

A fitted model: a lavaan object or a psychonetrics latent variable model (the latter needs the psychonetrics package).

filename

Output filename (with extension .png, .jpg, or .pdf).

output_path

Directory where the file is written. It has no default, so nothing is written unless you choose a location (use tempdir() for a temporary one).

width

Plot width in inches.

height

Plot height in inches.

resolution

Plot resolution in DPI.

node_labels

Optional character vector of node labels.

color_scheme

Optional list with elements man and lat for colors.

color_palette

Color palette type (default: "auto").

plot_settings

Optional list of semPaths plot settings.

device_settings

Optional list of device settings.

edge_settings

Optional list of edge display settings.

save_message

Logical; report the path of the saved file as a message (default: TRUE).

show_manifest

Logical; show manifest variables (default: TRUE).

Value

Invisibly, the path of the saved file. Called for its side effect: the diagram is written to file.path(output_path, filename).

Examples


set.seed(123)
n <- 300
f1 <- rnorm(n)
f2 <- 0.3 * f1 + rnorm(n)
items <- data.frame(
  sapply(1:4, function(i) 0.7 * f1 + rnorm(n, 0, 0.7)),
  sapply(1:4, function(i) 0.7 * f2 + rnorm(n, 0, 0.7))
)
names(items) <- c(paste0("A", 1:4), paste0("B", 1:4))

fit <- lavaan::cfa("F1 =~ A1 + A2 + A3 + A4
                    F2 =~ B1 + B2 + B3 + B4", data = items)
plot_latent_network_diagram(fit, filename = "diagram.png",
                            output_path = tempdir(), resolution = 100)


InterconectaR documentation built on Oct. 16, 2026, 1:06 a.m.