Attachment | Size |
---|---|

datawide.csv [6] | 9.21 KB |

Hi everyone,

I have a problem running multilevel model using a SEM framework to get a likelihood-based CI of the effect size. I have two factors representing (random) intercept and (fixed) slope. I attach my data file here. Use the following code to get the dataset:

datawide

The dataset has been transformed into a wide format. Y is the response variable. X is the upper-level predictor. Z is the lower-level predictor without any centering. My target model is

L1: Y = B_0 + B_1 * Z + r

L2: B_0 = X + u

I would like to find a likelihood-based CI of B_1 / sqrt(var(r) + (B_1^2 * var(Z)))

Here is my OpenMx script:

ylab zlab

colnames(datawide) latentLab

Alab Alab[7, 6] Alab[1:5, 8] Aval Aval[7, 6] Aval[1:5, 7] Aval[1:5, 8] Afree Afree[7, 6] colnames(Alab)

Slab diag(Slab) Slab[6, 6] Slab[7, 7] Slab[8, 8] Sval diag(Sval) Sval[6, 6] Sval[7, 7] Sval[8, 8] Sfree diag(Sfree) Sfree[8, 8] colnames(Slab)

Fval Flab Ffree colnames(Flab) rownames(Flab)

Mlab Mval Mfree colnames(Mlab)

onecov
mxData(datawide[,c(ylab, "x", zlab)], type="raw"),

mxMatrix(type="Full", nrow=8, ncol=8, values=Aval, free=Afree, labels=Alab, name="A"),

mxMatrix(type="Symm", nrow=8, ncol=8, values=Sval, free=Sfree, labels=Slab, name="S"),

mxMatrix(type="Full", nrow=6, ncol=8, values=Fval, free=Ffree, labels=Flab, name="F"),

mxMatrix(type="Full", nrow=1, ncol=8, values=Mval, free=Mfree, labels=Mlab, name="M"),

mxRAMObjective("A","S","F","M", dimnames=c(ylab, "x", latentLab)),

mxMatrix(type="Full", nrow=8, ncol=1, values=c(rep(0, 6), 1, 0), free=FALSE, name="s7"),

mxMatrix(type="Full", nrow=8, ncol=1, values=c(rep(0, 5), 1, 0, 0), free=FALSE, name="s6")

) # - end model

onecovfit summary(onecovfit)

This code works well. Next, I added two objects into the mxModel command

mxAlgebra(expression = A[7, 6], name = "alpha"),

mxCI(c("alpha"))

When I added these lines, the confidence interval can not be computed. Here is the error message:

Error: Could not find the dataset 'data' in model 'With covariate model' used by the definition variable 'data.z1'

However, when I ran the following codes, it works fine:

mxAlgebra(expression = S[7, 7], name = "alpha"),

mxCI(c("alpha"))

Do you have any suggestions on how to find the confidence interval that involves A[7, 6] which does not really involve with the definition variable? Thank you very much in advance.