library(lavaan)
library(semPlot)
mod_pa <-
'x1 ~~ x2
x3 ~ x1 + x2
x4 ~ x1 + x3
'
fit_pa <- lavaan::sem(mod_pa, pa_example)
m <- matrix(c("x1", NA, NA, NA,
NA, "x3", NA, "x4",
"x2", NA, NA, NA), byrow = TRUE, 3, 4)
p_pa <- semPaths(fit_pa, whatLabels = "est",
sizeMan = 10,
edge.label.cex = 1.15,
style = "lisrel",
nCharNodes = 0, nCharEdges = 0,
layout = m,
DoNotPlot = TRUE)
my_rotate_resid_list <- c(x3 = 45,
x4 = -45,
x2 = -90)
test_that("LISREL", {
expect_no_warning(p_pa3 <- rotate_resid(p_pa, my_rotate_resid_list))
})
# CFA
mod <-
'f1 =~ x01 + x02 + x03
f2 =~ x04 + x05 + x06 + x07
f3 =~ x08 + x09 + x10
f4 =~ x11 + x12 + x13 + x14
'
fit <- lavaan::cfa(mod, cfa_example)
p <- semPaths(fit, whatLabels="est",
sizeMan = 3.25,
node.width = 1,
edge.label.cex = .75,
style = "lisrel",
mar = c(10, 5, 10, 5),
DoNotPlot = TRUE)
indicator_order <- c("x04", "x05", "x06", "x07",
"x01", "x02", "x03",
"x11", "x12", "x13", "x14",
"x08", "x09", "x10")
indicator_factor <- c( "f2", "f2", "f2", "f2",
"f1", "f1", "f1",
"f4", "f4", "f4", "f4",
"f3", "f3", "f3")
test_that("LISREL", {
expect_no_warning(p2 <- set_cfa_layout(p,
indicator_order,
indicator_factor))
})
# SEM
mod <-
'f1 =~ x01 + x02 + x03
f2 =~ x04 + x05 + x06 + x07
f3 =~ x08 + x09 + x10
f4 =~ x11 + x12 + x13 + x14
f3 ~ f1 + f2
f4 ~ f1 + f3
'
fit <- lavaan::sem(mod, cfa_example)
p <- semPaths(fit, whatLabels="est",
sizeMan = 5,
node.width = 1,
edge.label.cex = .75,
style = "lisrel",
mar = c(5, 5, 5, 5),
DoNotPlot = TRUE)
indicator_order <- c("x04", "x05", "x06", "x07",
"x01", "x02", "x03",
"x11", "x12", "x13", "x14",
"x08", "x09", "x10")
indicator_factor <- c( "f2", "f2", "f2", "f2",
"f1", "f1", "f1",
"f4", "f4", "f4", "f4",
"f3", "f3", "f3")
factor_layout <- layout_matrix(f1 = c(1, 1),
f2 = c(3, 1),
f3 = c(2, 2),
f4 = c(2, 3))
factor_point_to <- layout_matrix(left = c(1, 1),
left = c(3, 1),
down = c(2, 2),
down = c(2, 3))
test_that("LISREL", {
expect_no_warning(p2 <- set_sem_layout(p,
indicator_order = indicator_order,
indicator_factor = indicator_factor,
factor_layout = factor_layout,
factor_point_to = factor_point_to))
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.