用3个波重新定位lavaan CLP模型的semPaths()元素

时间:2018-11-20 20:50:30

标签: r r-lavaan sem semplot

我正在寻找一种方法来重新定位semPlot::semPaths()元素的位置,这些元素来自具有三个时间点的lavaan::sem()拟合交叉滞后面板模型数据。

这是我跑步时得到的:

library(semPlot)
semPaths(fit1, edge.label.cex = .5, rotation = 2, style = "lisrel", 
         intercepts = FALSE, residuals = TRUE, curve = 1, curvature = 3, 
         nCharNodes = 8, sizeMan = 6, sizeMan2 = 3, optimizeLatRes = TRUE, 
         edge.color = "#000000")

enter image description here

在红色框中分为3个波浪。我想要的是这样的:(我不是这个情节的作者)

enter image description here

我的路径是正确的,但是无论我做什么,*t2波组都不会移动到图表的中心。反正还有吗?

有关完全可复制的示例,请运行以下命令:

library(lavaan)
library(semPlot)

df <- data.frame(CNt1=rnorm(100),
                 CNt2=rnorm(100),
                 CNt3=rnorm(100),
                 ISt1=rnorm(100),
                 ISt2=rnorm(100),
                 ISt3=rnorm(100),
                 SESt1=rnorm(100),
                 SESt2=rnorm(100),
                 SESt3=rnorm(100),
                 OUTt1=rnorm(100),
                 OUTt2=rnorm(100),
                 OUTt3=rnorm(100))
model1 <- '
CNt1 ~~ ISt1
CNt1 ~~ SESt1
CNt1 ~~ OUTt1
ISt1 ~~ SESt1
ISt1 ~~ OUTt1
SESt1 ~~ OUTt1

CNt2 ~~ ISt2
CNt2 ~~ SESt2
CNt2 ~~ OUTt2
ISt2 ~~ SESt2
ISt2 ~~ OUTt2
SESt2 ~~ OUTt2

CNt3 ~~ ISt3
CNt3 ~~ SESt3
CNt3 ~~ OUTt3
ISt3 ~~ SESt3
ISt3 ~~ OUTt3
SESt3 ~~ OUTt3

CNt2 ~ OUTt1 + CNt1 + ISt1 + SESt1
ISt2 ~ OUTt1 + CNt1 + ISt1 + SESt1
SESt2 ~ OUTt1 + CNt1 + ISt1 + SESt1
OUTt2 ~ OUTt1 + CNt1 + ISt1 + SESt1

CNt3 ~ CNt1 + OUTt2 + CNt2 + ISt2 + SESt2
ISt3 ~ ISt1 + OUTt2 + CNt2 + ISt2 + SESt2
SESt3 ~ SESt1 + OUTt2 + CNt2 + ISt2 + SESt2
OUTt3 ~ OUTt1 + OUTt2 + CNt2 + ISt2 + SESt2
'

fit1 <- sem(model1, data=df, fixed.x=FALSE)

semPaths(fit1, edge.label.cex = .5, rotation = 2, style = "lisrel", 
         intercepts = FALSE, residuals = TRUE, curve = 1, curvature = 3, 
         nCharNodes = 8, sizeMan = 6, sizeMan2 = 3, optimizeLatRes = TRUE, 
         edge.color = "#000000")

0 个答案:

没有答案