| plot_lvm | R Documentation |
Creates visualizations for psychonetrics latent variable models.
plot_lvm(
x,
plot = c("network", "loadings", "residcors", "residpcors", "latents"),
ask,
rotation = promax,
vsize = c(5, 5),
palette = "Set1",
...
)
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. |
Invisible list of qgraph objects.
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"))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.