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

GMM.R | 2.53 KB |

Hi,

I have a script for the 2-class growth mixture model (please see attached). I am wondering if I can add covariate (say x1) as a covariate of my model. I may want to see the effect of x1 on the latent classes only and also of it on both latent classes and the growth factors. As my understanding, in MPlus, the first scenario can be expressed as "c#1 on x1" and the second one can be written as "c#1 on x1" and "int on x1; slp on x1" of each class, but I have zero idea to translate to OpenMx. Any advice would be appreciated.

I would change

to

The R object

`classPM`

is a 2x2 matrix of the base weights: the first row is for the first class; the second row is for the second class. The first column of`weightsM`

gets multiplied by 1; the second column gets multiplied by the variable`X1`

. This results in the R object`classP`

and the OpenMx object`weights`

. Include`classPM`

,`classV`

, and`classP`

in the`gmm2`

model accordingly.Hi Michael,

Thanks for your kind reply. I tried to update my codes but got an error: "In model 'GMM2Class' the name 'p21' is used as a free parameter in 'GMM2Class.weightsM' and as a fixed parameter in 'GMM2Class.weightsM'". I don't know why. I am attaching script and data I used, could you kindly help me to figure it out? Thank you very much!

This syntax appears to be the culprit:

Try changing one of the redundant "p21" labels to something else ("p12", perhaps?).

I had a typo in my example code. I edited it to be correct now with a note that I edited it.

Hi Michael,

I really appreciate your correction. It works now. I am wondering the interpretation of p11-p22 if I calculate the weights in your script. They are not $\beta$'s in the formula, right? Can I have those $\beta$'s?

No, the p11-p22 should be the $\beta$s: $pij = \beta_{i-1}^{(j)}$ or more specifically $p11 = \beta_0^{(1)}$, $p12 = \beta_1^{(1)}$, $p21 = \beta_0^{(2)}$, and $p22 = \beta_1^{(2)}$.

Hi Michael,

I also tried to write several lines to estimate $\beta$'s from above formula (please see the attached), which may have initial value or model specification issue. Do you have tips about it? Any advice would be appreciate.

It looks like your code is using an algebra fit function instead of the built-in mixture modeling. See relevant section from your code below.

I would change this to

Now it works well! Thanks for your kindest advice!

Wunderbar!