library(lavaan)
library(semPlot)
mod <-
'f1 =~ x01 + x02 + x03
f2 =~ x04 + x05 + x06 + x07
f3 =~ x08 + x09 + x10
f4 =~ x11 + x12 + x13 + x14
'
fit_cfa <- lavaan::sem(mod, cfa_example)
lavaan::parameterEstimates(fit_cfa)[, c("lhs", "op", "rhs", "est", "pvalue")]
p <- semPaths(fit_cfa, whatLabels="est",
sizeMan = 2.5,
nCharNodes = 0, nCharEdges = 0,
edge.width = 0.8, node.width = 0.7,
edge.label.cex = 0.6,
style = "ram",
mar = c(10,10,10,10))
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")
p2 <- set_cfa_layout(p, indicator_order,
indicator_factor,
fcov_curve = 1.5,
loading_position = .8)
plot(p2)
# Use a named vector for indicator_order
indicator_order2 <- c(f2 = "x04", f2 = "x05", f2 = "x06", f2 = "x07",
f1 = "x01", f1 = "x02", f1 = "x03",
f4 = "x11", f4 = "x12", f4 = "x13", f4 = "x14",
f3 = "x08", f3 = "x09", f3 = "x10")
p2 <- set_cfa_layout(p,
indicator_order = indicator_order2,
fcov_curve = 1.5,
loading_position = .8)
plot(p2)
# Use automatically generated indicator_order and indicator_factor
p2 <- set_cfa_layout(p,
fcov_curve = 1.5,
loading_position = .8)
plot(p2)
p2 <- set_cfa_layout(p, indicator_order,
indicator_factor,
fcov_curve = 1.5,
loading_position = .8,
point_to = "left")
plot(p2)
p2 <- set_cfa_layout(p, indicator_order,
indicator_factor,
fcov_curve = 1.5,
loading_position = .8,
point_to = "up")
plot(p2)
p2 <- set_cfa_layout(p, indicator_order,
indicator_factor,
fcov_curve = 1.5,
loading_position = .8,
point_to = "right")
plot(p2)
Run the code above in your browser using DataLab