plot_lvm: Plot Latent Variable Models

View source: R/plot_lvm.R

plot_lvmR Documentation

Plot Latent Variable Models

Description

Creates visualizations for psychonetrics latent variable models.

Usage

plot_lvm(
  x,
  plot = c("network", "loadings", "residcors", "residpcors", "latents"),
  ask,
  rotation = promax,
  vsize = c(5, 5),
  palette = "Set1",
  ...
)

Arguments

x

A psychonetrics model object.

plot

Types of plots to create (network, loadings, residcors, residpcors, latents).

ask

Logical, whether to ask before each plot.

rotation

Rotation function (default promax).

vsize

Node size vector (default c(5, 5)).

palette

RColorBrewer palette name (default "Set1").

...

Additional arguments passed to qgraph.

Value

Invisible list of qgraph objects.

Examples


if (requireNamespace("psychonetrics", quietly = TRUE)) {
  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))

  lambda <- matrix(0, 8, 2)
  lambda[1:4, 1] <- 1
  lambda[5:8, 2] <- 1
  mod <- psychonetrics::lvm(items, lambda = lambda, verbose = FALSE)
  mod <- psychonetrics::runmodel(mod, verbose = FALSE)
  plot_lvm(mod, plot = c("loadings", "latents"))
}


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