Hi,

Are there any example scripts for how to add a definition variable to a RAM model, and how to then use that in an algebra on a path?

Here's one adding a definition variable for means, but not including its value in an algebra, and then using that algebra to se the value for another path.

https://openmx.ssri.psu.edu/docs/OpenMx/2.5.1/DefinitionMeans_Path.html

inst/models/nightly/univACErSEM.R

Thanks Josh,

Wanting an example to point people to with comments on most lines explaining how the script works. Also one just showing "Here is how to create a moderated path in RAM" rather than more complex example for learning.

Reading through univACErSEM.R now: The definition variables are used on paths directly, rather than being used to moderate a path (i.e., compute the path based on the definition variable. e.g.

This example shows how a def var can be used to moderate the effect of x on y by faking a latent variable which is set to have a mean equal to

`def`

, and having a path from x to y go via this latent variable.But can it be extended to the typical case of

?

i.e., to include the def on the diagram as a manifest, and use it as a definition variable?

Hi,

I am interested in estimating a GxE biometric twin model using the RAM notation. However, I am not sure how to implement the moderation with the path notation. Could you give me a hint if it is possible and if so how one can code it within OpenMx?

Yes, it's possible to do that with RAM specification. I don't have an example handy, though. However, I honestly think RAM is more trouble than it's worth for that kind of model.

If the model you want to fit is fairly basic, you can probably do it pretty easily in the umx package, with one of its

`umxGxE*`

functions.I drew this model with Onyx and used to OpenMx (path) to obtain a script. Obviously it needs work in the sense of two groups with the same model except for the correlation between the twins' additive genetic factors. But it may get you started. If you download Onyx from https://onyx-sem.com then you can load the diagram from the .xml file which has been renamed to .txt to enable upload here.

Mostly, the moderation trick is to draw two paths, e.g., from A to P, one goes direct and is the unmoderated bit, and the other goes first to a latent variable that has no double-headed arrow or other variance to itself, and then from that latent variable to P. Put moderation parameter on one path, and the definition variable for the moderator on the other, and the two together operate as if the algebra (a + b * Mod) had been directly specified as a formula on a path.

Great, that's very helpful. I will try this out. Yes umx is nice but I want to build a biometric LGC with some moderated paths and using the path specification seems to be a intuitive first step (and to check some scripts based on the matrix specification).