r中的路径图

Path diagram in r

我正在尝试在 R 中绘制结构方程模型 (SEM) 的路径图。我能够使用 semPlot::semPaths() 绘制它。输出类似于 SEM 是使用 lavaan 包建模的。

我想要一个类似于的情节。具有估计值和 p 值。谁能帮帮我?

检查这个例子,它可能会有帮助 https://rstudio-pubs-static.s3.amazonaws.com/78926_5aa94ae32fae49f3a384ce885744ef4a.html

我的建议是 lavaanPlot(在 author's personal website 中查看更多内容):

library(lavaan)
library(lavaanPlot)
# path model
model <- 'mpg ~ cyl + disp + hp
          qsec ~ disp + hp + wt'

fit1 <- sem(model, data = mtcars)
labels1 <- list(mpg = "Miles Per Gallon", cyl = "Cylinders", disp = "Displacement", hp = "Horsepower", qsec = "Speed", wt = "Weight") #define labels
lavaanPlot(model = fit1, labels = labels1, coefs = TRUE, stand = TRUE, sig = 0.05) #standardized regression paths, showing only paths with p<= .05