The revisions let you track differences between multiple versions of a post.

TODO: basic information on using mxMatrix() to go here

This feature allows you to construct MxMatrix objects, the labels of which refer to another MxMatrix or MxAlgebra. This is done by specifying the name, row, and col of the target matrix or algebra as you would expect to be able to in R, i.e., "foo[row,col]".

The effect of pointing to another cell using bracket notation is just the same as setting the label of the two cells to the same value.

So, given a matrix A with labels:

aLabels = c( "a1", "a2", "a3", "a4", )

Setting the labels of matrix B to this:

bLabels = c( "a1", "b2", "b3", "b4", ) <em>#forces cell B[1,1] to take the same value as A[1,1] </em>

Is the same as setting the labels of matrix B to this:

bLabels = c( "A[1,1]", "b2", "b3", "b4", ) <em>#forces cell B[1,1] to take the same value as A[1,1] </em>

**Caveates**: This feature of substitution applies only to matrix labels and cannot be used in mxAlgebra expressions.

require(OpenMx) A <- <strong>mxMatrix</strong>('Full', 1, 1, values = 1, name = 'A') B <- <strong>mxMatrix</strong>('Full', 1, 1, values = 2, name = 'B') C <- <strong>mxMatrix</strong>('Full', 1, 1, values = 3, name = 'C') D <- <strong>mxMatrix</strong>('Full', 3, 1, labels = c('A[1,1]', 'B[1,1]', 'C[1,1]'), name = 'D') model <- <strong>mxModel</strong>('model', A, B, C, D) fit <- <strong>mxRun</strong>(model) mxEval(D, fit)

A <- <strong>mxMatrix</strong>('Full', 2, 2, values = c(1,2,3,4), byrow = TRUE, name = 'A') B <- <strong>mxAlgebra</strong>(A + A, name = 'B') C <- <strong>mxMatrix</strong>('Full', 2, 2, labels = c('B[2,2]', 'B[2,1]', 'B[1,2]', 'B[1,1]'), byrow = TRUE, name = 'C') model <- <strong>mxModel</strong>('model', A, B, C) fit <- <strong>mxRun</strong>(model) mxEval(C, fit)

- Login or register to post comments
- Printer-friendly version
- Login or register to post comments
- Send to friend