I thought this might be useful for those new to OpenMx (like myself) who are trying out the matrix specifications way of specifying latent growth curves. I ran into a bug when declaring a lgc model where the input method was 'cov' rather than 'raw', and since I couldn't figure out how to fix it directly I composed a step around way to do it. I believe that this issue is well known since the links from the current OpenMx Users Manual for

http://openmx.psyc.virginia.edu/repoview/1/trunk/demo/LatentGrowthCurveModel_MatrixCov.R

http://openmx.psyc.virginia.edu/repoview/1/trunk/demo/LatentGrowthCurveModel_PathCov.R

are not functioning, so in the meantime this way should suffice. What I did was compose a function that, given a cov matrix, a means vector, and sample size, returns an arbitrary raw data matrix that perfectly reproduces the declared moments. That way instead of having to state that the input='cov' users could just stay with the input='raw' way that is currently stable and functioning.

I have attached a revised demo file (from LatentGrowthModel_MatrixRaw.R in the manual) to demonstrate the problem and my solution. Love the OpenMx program so far, hope it continues to grow. Cheers!

Phil

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

LatentGrowthCurveModel_MatrixRaw (revised).R | 9.4 KB |

In a RAM model that contains an expected means matrix ('M'), matrix dimnames are needed for the filter matrix and the expected means matrix. In the filter matrix, only column names are necessary. The rows are filters and are unnamed. The M matrix is a column vector and so only column names are necessary. In the script, this can be accomplished in one of two ways.

Let the variable:

`dims <- c(names(myLongitudinalData), "intercept", "slope")`

Then we can specify in the mxMatrix() declarations for the 'F' and 'M' matrices the dimnames with the argument:

`mxMatrix(type=, nrow=, ncol=, name=, dimnames=list(NULL, dims))`

A second way to specify the dimnames is to use the argument 'dimnames' in the mxRAMObjective() function. This argument takes a single vector, and the objective function has the information to know which row or column names must be populated in which matrices. The second way looks like:

`mxRAMObjective("A","S","F","M", dimnames = dims)`

Thanks Michael. That is much simpler than my solution. Cheers!