sem
sem copied to clipboard
appendix parallel process: add brms and correlations
The parallel process depiction leaves out intercept/slope correlations that would probably be included in models. Also would be good to show the equivalence as multivariate random effect model via brms.
For example, update the main model as:
mainModel = "
i1 =~ 1*y11 + 1*y12 + 1*y13 + 1*y14
s1 =~ 0*y11 + 1*y12 + 2*y13 + 3*y14
i2 =~ 1*y21 + 1*y22 + 1*y23 + 1*y24
s2 =~ 0*y21 + 1*y22 + 2*y23 + 3*y24
s1 ~ i2
s2 ~ i1
i1 ~~ s1
i2 ~~ s2
"
And for brms
library(tidyverse)
library(brms)
head(d2)
d = left_join(d1, d2)
form = bf(y1 ~ time + (1 + time | p | Subject)) +
bf(y2 ~ time + (1 + time | p | Subject))
mod = brm(form, data = d, cores=4)
summary(mod)
For identity you will have to fix variances in lavaan or model sigma by time for brms.