# Multilevel model

3 posts / 0 new
Offline
Joined: 08/05/2016 - 02:03
Multilevel model

Hi all!

First, thanks a lot for a great program! I have recently been exploring the multilevel possibilities in OpenMx. This is really cool! I am now working on a model where I induce the appropriate additive genetic relationships among subjects via identifiers for their parents. I therefore have a "Children" model with observed responses, and a "Mother" model and a "Father" model without any observed responses. However, the latent additive genetic variables in the "Children" model is regressed with 0.5 on the corresponding latent additive genetic variables in the "Mother" and "Father" model. This all works excellent, and makes it really easy to include larger pedigrees in the analyses. However, if I want to reduce the model and fix the additive genetic variance to zero, I get an error because the S matrix in the "Mother" and "Father" is zero. The code for this model is a bit long, so instead I have attached a simple example of a "random intercept" model to try to illustrate the problem:

library(OpenMx)

J = 10
I = 5
U = rnorm(J)
jj = rep(1:J, each = I)
y = U[jj] + rnorm(I*J)
D_B = data.frame(jj = 1:J)
D_W = data.frame(y, jj)

lat_B = "u"
mod_B = mxModel("B", type = "RAM", latentVars = lat_B,
mxData(D_B, "raw", primaryKey = "jj"),
mxMatrix("Full", 1, 1, F, 0, lbound = 0, name = "S", dimnames = list(lat_B, lat_B)),
mxMatrix("Zero", 1, 1, name = "A", dimnames = list(lat_B, lat_B)),
mxMatrix("Zero", 0, 1, name = "F", dimnames = list(NULL, lat_B)),
mxMatrix("Zero", 1, 1, name = "M", dimnames = list(NA, lat_B)),
mxExpectationRAM("A", "S", "F", "M"))
man_W = "y"
mod_W = mxModel("W", type = "RAM", mod_B,
manifestVars = man_W,
mxData(D_W, "raw"),
mxMatrix("Full", 1, 1, T, 1, lbound = 0, name = "S", dimnames = list(man_W, man_W)),
mxMatrix("Zero", 1, 1, name = "A", dimnames = list(man_W, man_W)),
mxMatrix("Iden", 1, 1, name = "F", dimnames = list(man_W, man_W)),
mxMatrix("Full", 1, 1, T, 0, name = "M", dimnames = list(man_W, man_W)),
mxMatrix("Full", 1, 1, F, 1, name = "T",
joinKey = "jj", joinModel = "B", dimnames = list(man_W, lat_B)),
mxExpectationRAM("A", "S", "F", "M", between = "T"))
fit = mxRun(mod_W)
summary(fit)

Because the S matrix in "mod_B" is zero, I get an error. I'am wondering if it exists any easy workaround for this? I can see that there are alternative ways to specify models to get around this. However, in the application that I am working on, it would make it really easy to define sub-models if zero S matrices were allowed.

All the best,

Espen Moen Eilertsen

Offline
Joined: 05/24/2012 - 00:35
good point

This is fixed in v2.9.4-26-g5639b759f

Offline
Joined: 08/05/2016 - 02:03
Great. Thank you!

Great. Thank you!