Mon, 03/03/2014 - 16:14

I'm trying to run a model in which I have several matrices that should contain the same parameter estimates (they overlap partly). I know I can use labels or mxConstraint to put equality constraints on parameter estimates, but I was wondering if it is also possible to refer directly to the parameter estimates of a matrix in other parts of the OpenMx environment. For example, I have tried to build an mxAlgebra that refers to the parameter estimates of an mxMatrix by using:

mxAlgebra(expression=cbind(Model.mxMatrix[,i],Model.mxMatrix[,j]), name="part_mxMatrix")

but this doesn't seem to work.

If anybody has any suggestion on how to make this work, it is more than welcome!

The following code works.

Based on your example I think I know where you might be heading wrong. In OpenMx, you can refer to the entries of an mxMatrix either by the labels associated with that entry, or by the name of the matrix followed by square brackets (e.g. A[1,2]). However, the square brackets don't work quite like they do in the rest of R. The square brackets must contain numeric literals only, no variables (e.g. A[i,j] ) and no blanks (e.g. A[,]).

If you want the entire row of a matrix, you could refer to each element of that row or you could create a matrix, C, of ones and zeros that selects out the desired row via matrix multiplication (i.e. A[i,] == C %*% A).

Here's an R code snippet of row extraction via matrix multiplication.