Hi all,
I am conducting latent basis models and have got estimations. I want to plot the functional form of individuals. Is there any way for OpenMx to plot those y hat's for each individual automatically? Or at least can I have those y hat values directly?
Thank you in advance!
Hi Veronica
Can you clarify? Do you simply want the expected mean for each row? Or do you also want a function of the estimated factor scores, a la fitted.lme?
For the former, the mxGetExpected() will deliver the model expected means, and its defvar row argument could be apply'd to obtain the predicted means when there are definition variables involved that make the expected means differ between data rows.
Thanks
Mike
Dr. Neale,
Thanks for your kind reply. I tried the function mxGetExpected() at your suggestion and got mean vectors and variance-covariance matrix of outcomes (i.e., the variable BMI in my case, shown below). It is great to know the model-based mean and var-cov matrix of outcomes, which can be compared to the means and var-cov matrix from the data summary. However, we are more interested in such model-based values for each individual (I understand your point about using "defvar" to specify covariates, but we do not have such covariates/definition variables; we only have repeated outcomes). Can I get such values by some existed functions?
It's not entirely clear to me what you're trying to do. I'm not very familiar with the kind of LGC you're fitting, so it would help if you post your script and explain what it's meant to do.
If you start with something like the demo called
LatentGrowthCurveModel_PathRaw
which can be run withThen you only need a few extra lines to get what you want. The real code here is just four lines, but there's some extra inspection and comments.
The general idea here is to (1) get the regression factor scores, (2) get the latent-to-observed variable map (i.e. factor loadings), and then (3) compute the predicted observed scores based on the factor scores and the mapping. Finally, a simple plot is made with
matplot
.