We've had a request for a function that changes the dimensions of a matrix.

Maybe `mxRedim(mat, row, col)`

? Conformance would require that the total number of elements remain constant. That is, `mat->rows mat->cols == row col`

.

Semantics would probably fill in by columns.

Not sure what the utility of this is... but sounds like a function for the genEpi_ library?

genEpi_Redim(mxMatrix, newRows, newCols)

Can anyone say why it is helpful?

Yes, suppose you wish to fit a 3 factor model but currently have a matrix-style script for a 2 factor model in which the factor loadings are in the two columns of matrix L. A redim to 3 columns would add a factor (though some zeroing of a couple of elements may be necessary for model identification).

Given the nature of R's pass-by-value, a new matrix would need to be built anyway. So, it seems as if a general solution might be to implement something like (and yes, I know this is bizarre, so maybe there is a better way to implement it):

This would place the 2x2 matrix A into the submatrix [2:3,2:3] of matrix B. This makes sense from an R-ish perspective, but I'm not so sure that it could be implemented without a lot of hackery.

All of this argues for a style of model building where you create your mxMatrix pieces ahead of time. Lately I've been experimenting with this style to see how it works. It tends to look something like this in practice:

This is an example of the specification of an A matrix that is entirely independent of how many factors and indicators in a fully cross-loaded factor model. This is currently easier in path-style, but sometimes one needs to use matrices.

The advantage is that I can change just about anything and the just pump it into a new mxMatrix of any order. The disadvantage is having to keep track of the three sets of component matrices in the mxMatrix.