R语言 路径图:潜在增长曲线模型定制

jjhzyzn0  于 2023-10-13  发布在  其他
关注(0)|答案(1)|浏览(105)

我在lavaan中创建了一个潜在增长曲线模型,并创建了一个路径图来表示它。然而,在路径图上,我想...
1.删除特定变量的截取数据;预测变量(x1)和指标变量(T0/Year 0、T1/Year 1、T2/Year 2和T3/Year 3)。
1.在图中包含估计值的置信区间
我看不出如何使用现有的功能来做到这一点-有没有变通的办法?
提前感谢!

# Load relevant packages
library(lavaan) #for SEM LGCM
library(semTools) # for fit indices 
library(semPlot) # for path diagrams
library(semptools) # for path diagrams
library(tidyverse) # pipelines, exploring and visualizing data

# model
model_fit <- ' 
# intercept with fixed coefficients
  i =~ 1*T0 + 1*T1 + 1*T2 + 1*T3
# slope with fixed coefficients
  s =~ 0*T0 + 1*T1 + 2*T2 + 3*T3

# time invariant covaraites
 # regression of time-invariant covariates on intercept and slope factors
  i ~  x1 + covar1 + covar2 + covar3
  s ~ x1 + covar1 + covar2 + covar3
'

fit <- growth(model_fit, data=LGCM_data, missing="fiml", estimator = "MLR")
summary(fit,fit.measures=TRUE, ci=TRUE)

# Plot   
lgcm_no_covs <- semptools::drop_nodes(
                 object = semPlotModel(fit),
                 nodes = c("covar1", "covar2", "covar3")) 

lgcm_no_covs <- semPaths(lgcm_no_covs, whatLabels = "est",
                    label.norm = "PAL \nBaseline",
                    edge.label.cex = 1.0, label.cex = 2.0,
                    edge.color = "black", edge.label.color = "black",
                    height = 20, width = 12,
                    residuals = FALSE,
                    DoNotPlot= TRUE)  

my_label_list <- list(list(node = "i", to = "Intercept"),
                     list(node = "s", to = "Slope"),
                     list(node = "x1", to = "Predictor"),
                     list(node = "T0", to = "Baseline"),
                     list(node = "T1", to = "Year 1"),
                     list(node = "T2", to = "Year 2"),
                     list(node = "T3", to = "Year 3")
                     )

lgcm_no_covs <- change_node_label(lgcm_no_covs, my_label_list)

plot(lgcm_no_covs)

hfsqlsce

hfsqlsce1#

目前不支持只绘制部分截距,也不支持绘制置信区间。

相关问题