Attachment | Size |
---|---|
OpenMx Single Level Model ESA.R [6] | 2.18 KB |
Snapshot Data.PNG [7] | 30.53 KB |
Hello all,
I posted this question in the Mixed Effects and Nested Models discussion board, but haven't heard back in a few weeks and my analysis is a bit time-dependent.
I know similar questions have been posted here but I'm still unable to figure out the code for my model, as I am super new to OpenMx and structural equation modeling in general. I have data from a cluster-randomized RCT, collected at three time-points on children nested within schools. I would like to look at the effect of the intervention over time for the children, but taking the clustering from the schools into account. I'm trying to get my structural equation model to match this mixed model (with the data in long format) from the nlme package:
MixedModel <- lme(ESA ~ Time + trtGrp + Time*trtGrp,
random = list(School = ~1, idChild = ~1),
weights =varIdent(School),
corr = corCompSymm(form= ~Time),
data=DataSet,
method = "REML")
where ESA is the outcome (emotional self-awareness), Time is as a factor variable (so gives the slopes from Time 1 [ref] to Time 2, and Time 1 to Time 3), trtGrp is the intervention group, and the variance/covariance matrix for the three time-points is compound symmetry. The intercept is random ONLY for Schools. The intercept is fixed for Children, and the slope is fixed for both Children and School.
For structural equation modeling, I've been using a latent growth curve, with the data in wide format. Since the measures are not linear from T1 to T3, I've created two slopes (t1 to t2, and t1 to t3). The bit I'm struggling with is adding a random intercept for schools in OpenMx. I've attached my script to this post, as well as a screenshot of part of my data.
With this model, I can match everything to my mixed model except for the school intercept variance (since I haven't added it in here). I have no idea how to add another level, or how to add it so that the only thing it does is give a random intercept for School. Someone did respond to my original post and pointed me to this example: https://github.com/OpenMx/OpenMx/blob/master/inst/models/passing/xxm-2.R
However, I'm still unable to figure out how to make this work for my own data. Again, all I really need is for the intercept to be random at the School level, everything else is a fixed effect. If anyone is able to help, I would greatly appreciate it!
Thanks so much!