Could anybody tell how to correct the following mxAlgebra statement to get the real eigenvalue parts of a matrix A
eigen<-mxAlgebra(Re(eigen(A,only.values=TRUE)$values),"eigen")
When running the model I get the error message:
Error: Unknown reference 'TRUE' detected in the entity 'eigen' in model 'eigen-example'
Unfortunately, not all operations in R are implemented in our computational backend. The operations that are currently defined are listed in the OpenMx wiki page Matrix Operators and Functions.
I'd be happy to add Re() and eigen() to the list of requested functions.
Yeah. This functionality is in Mx 1.0 using the functions \eval() and \evec(). We should get around to implementing them in OpenMx. We will probably implement a subset of the R function eigen() that does not use either named arguments or boolean arguments, since OpenMx does not support either of these constructs. I think we'll write one function in R that does
and another that does
That seems like a good solution. Does that work for you, Han?
Steve and mspiegel,
Could you also implement the imaginary parts
Im(eigen(foo, only.values = TRUE)$values) # omxEigenRealVal?
and
Im(eigen(foo)$vectors) # omxEigenRealVec?
as well as the exponential function exp()? All three are announced in the OpenMx reference Manual and are for me the main reason to change from Mx to openMx. I would be happy to be able to take the exponential function of complex eigenvalues as it is possible in R. Thanks. Han
That sounds like a good idea to me. The imaginary parts are also in Mx 1.0 (they are \ival() and \ivec()), so we should support them.
Is eigen() still on the list of things to do?
?eigenvec
for details.There are different functions for real and imaginary parts, and different functions for eigenvectors and eigenvalues.
Just a note, these are pretty slow right now. But they work, and are implemented in both the 1.0 release and the developer's trunk.
Thanks! Sorry for the silly question --- I didn't see them under ?mxAlgebra, so I missed them.
Dear all,
just to make sure I understand things correctly: There is currently no way to compute a matrix exponential in openMx, right? In Mx this was possible via the eval() and evec() functions, but both are not (yet) implemented in openMx, right? Are you planning to implement these functions soon? Thank you so much for your help!
That is correct, an analogous function for classic Mx eval() and evec() have not been implemented. The earliest we can implement them is sometime in March.
thank you for your fast reply. March would be great - we are desperately looking forward to these functions!
As of OpenMx 0.3.0, the eigenvec and eigenval (as well as ieigenvec and ieigenval, for the imaginary parts) have been implemented for eigenvector and eigenvalue decomposition.
Please give them a try--we welcome your comments.
Dear mspiegel,
Just out of curiosity. Your implementations of Mx algebra functions are also in R? Where can I find e.g. how function mxAlgebra(sin(),name="") looks like in R?
Han
Ah. So each matrix operator or function that is supported by OpenMx is implemented twice. One of these implementations is the operator/function as supported in the R language. So the sin() function is the R primitive for the trigonometric function. The implementation of the R primitive is available in the R source code. But each matrix operator or function is also implemented by the OpenMx developers in C. This is because we use a FORTRAN numeric optimizer and compute the algebra expression in C without any callbacks to the R interpreter. To see our implementation of the matrix functions you can look at http://openmx.psyc.virginia.edu/repoview/1/trunk/src/omxAlgebraFunctions.c. To see the mapping of names look at http://openmx.psyc.virginia.edu/repoview/1/trunk/data/omxSymbolTable.tab. The 3rd column is the name in R, and the 5th column is the function name in C.
I am trying to run a statement: mxAlgebra(cbind(min(Re(eigen(mzmef, only.values=T)$values)), min(Re(eigen(corDZM, only.values=T)$values))), name =xy). First I got an unknown reference to T; I changed it to mxAlgebra(cbind(min(Re(eigen(mzmef, only.values==T)$values)), min(Re(eigen(corDZM, only.values==T)$values))), name =xy) and got an unknown reference to only.values. I was wondering if there is a work around.
Thank you!
The OpenMx functions are named eigenval, eigenvec, ieigenval, and ieigenvec. See
.