admin管理员组文章数量:1401444
In a RI-CLPM with three time-invariant predictors I would like to include paths between the predictors using lavaan (R package).
There are two observed variables at three measurement points (x1, x2, x3 and y1, y2, y3), which are metric, and three time-invariant predictors (pre1, pre2, pre3), where pre1 and pre3 are binary and pre2 is metric. There are no missing values for the binary predictors, but there are missing values for the metric predictor and the other variables. Besides estimations of autoregressive and cross-lagged effects (within-person level), the observed variables x1, x2, x3, y1, y2 and y3 are regressed on the three predictors. Further, I would like to include paths between the predictors: the predictor pre3 (binary) is regressed on pre1 (binary) and pre2 (metric), like: pre3 ~ pp1* pre1 + pp2* pre2.
The code for the RI-CLPM is based (and adapted) on the article of Hamaker et al. (2015) and the following site: /riclpm-lavaan-demo.html. The code for the extension with the predictors is based (and adapted) on the article of Mulder & Hamaker (2021) and this site: .html#extension-1-including-time-invariant-predictors-and-outcomes. The code works, if I don’t include the paths between the predictors (see the code without the paths between the predictors below).
Unfortunately, I don’t know how to specify the paths between the predictors or include this in the model fit, so that it works. I assume the problem in the code for the model fit. I tried to search for it and tried different things but couldn’t find any solution. It probably needs another coding for the binary predictor variable (pre3) in the model fit. While searching, I came across the ordered =
argument and the estimator WLSMV
, but I couldn't figure out how to integrate that into the code.
I am very thankful for any help to modify the code to include the paths between the predictors.
#### R Code RI-CLPM with predictors ####
## predictors ##
# pre1 (0,1), pre2 (metric), pre3 (0,1)
## manifest variables (metric) ##
# x1, x2, x3
# y1, y2, y3
riclpmModel_with_predictors <-
'
#latent mean structure with intercepts
RI_x =~ 1* x1 + 1* x2 + 1* x3
RI_y =~ 1* y1 + 1* y2 + 1* y3
x1 ~ mu1*1 #intercepts
x2 ~ mu2*1
x3 ~ mu3*1
y1 ~ pi1*1
y2 ~ pi2*1
y3 ~ pi3*1
RI_x ~~ RI_x #variance
RI_y ~~ RI_y #variance
RI_x ~~ RI_y #covariance
#latent variables for autoregressive and cross-lagged effects
x1_latent1 =~ 1* x1 #each factor loading set to 1
x2_latent2 =~ 1* x2
x3_latent3 =~ 1* x3
y1_latent1 =~ 1* y1
y2_latent2 =~ 1* y2
y3_latent3 =~ 1* y3
# autoregressive and cross-lagged effects
x3_latent3 ~ alpha3* x2_latent2 + beta3* y2_latent2
x2_latent2 ~ alpha2* x1_latent1 + beta2* y1_latent1
y3_latent3 ~ delta3* y2_latent2 + gamma3* x2_latent2
y2_latent2 ~ delta2* y1_latent1 + gamma2* x1_latent1
x1_latent1 ~~ x1_latent1 #variance
x2_latent2 ~~ u2* x2_latent2
x3_latent3 ~~ u3* x3_latent3
y1_latent1 ~~ y1_latent1 #variance
y2_latent2 ~~ v2* y2_latent2
y3_latent3 ~~ v3* y3_latent3
x1_latent1 ~~ y1_latent1 # covariance
x2_latent2 ~~ y2_latent2 # covariance
x3_latent3 ~~ y3_latent3 # covariance
# predictor effects
x1 ~ px11* pre1 + px12* pre2 + px13* pre3
x2 ~ px21* pre1 + px22* pre2 + px23* pre3
x3 ~ px31* pre1 + px32* pre2 + px33* pre3
y1 ~ py11* pre1 + py12* pre2 + py13* pre3
y2 ~ py21* pre1 + py22* pre2 + py23* pre3
y3 ~ py31* pre1 + py32* pre2 + py33* pre3
'
riclpmModel_with_predictors_fit <- lavaan(riclpmModel_with_predictors, data = data_xy,
missing = 'ML', #for the missing data
int.ov.free = F,
int.lv.free = F,
auto.fix.first = F,
auto.fix.single = F,
auto.cov.lv.x = F,
auto.cov.y = F,
auto.var = F)
summary(riclpmModel_with_predictors_fit, standardized = T)
版权声明:本文标题:r - How to include paths between time-invariant predictors in a RI-CLPM in a code using lavaan? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744201118a2594966.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论