You are here

An mxAlgebra to resize a matrix

Duplicate the R behavior of matrix(1:12, 3, 4) as an OpenMx algebra.

Reporter: 
Created: 
Thu, 01/24/2013 - 13:50
Updated: 
Thu, 09/15/2016 - 10:32

Comments

Is the innovation here not so much resize, but allowing the creation of greater than 1×1 matrices in algebra (we've only allow automatic up-shifting of number into a 1×1 matrix till now?

This would allow creation of arbitrary matrices (which is useful), but I think was decided against in the past?

perhaps supporting matrix in an algebra would be enough...

  mxMatrix(name="a", values = 1:12, nrow=3,ncol=4)
  mxAlgebra(matrix(a,1,12), name = "vector")

mxAlgebras can currently evaluate to any arbitrary size matrix, e.g. solve(I-A) %% S %% t(solve(I-A)) often is an NxN matrix. The innovation is mostly that you could take a vector, restructure it as a matrix, and then use matrix operations on the new matrix.

Yes, I was meaning not that algebras can't output arbitrary matrices, but that these are all illegal, no?

 mxAlgebra(mxMatrix("Full",3,4,values=c(1:12)), name="a"),
    mxAlgebra(matrix(c(1:12),3,4), name="b"),
    mxAlgebra(c(1:12), name="c"),

Not a good idea to have unnamed objects, and auto-named objects