在 R 中使用 lavaan 的結構方程模型
Erin Buchanan
Professor
library(lavaan)
library(semPlot)
twofactor.model <- 'text =~ x4 + x5 + x6
speed =~ x7 + x8 + x9'
twofactor.fit <- cfa(model = twofactor.model,
data = HolzingerSwineford1939)
semPaths(object = twofactor.fit)

semPaths(object = twofactor.fit,
whatLabels = "std",
edge.label.cex = 1)
#whatLabels 也可用 "par"

semPaths(object = twofactor.fit,
whatLabels = "std",
edge.label.cex = 1,
layout = "circle")
#layout 選項:tree、circle、spring、tree2、circle2

semPaths(object = twofactor.fit,
whatLabels = "std",
edge.label.cex = 1,
layout = "tree", rotation = 2)
#tree 版面的 rotation 選項為 1、2、3、4

semPaths(object = twofactor.fit,
whatLabels = "std",
edge.label.cex = 1,
layout = "tree", rotation = 2,
what = "std", edge.color = "purple")
#what 選項包含 par 與 std

在 R 中使用 lavaan 的結構方程模型