## eigenvalues

16 replies [Last post]
Offline
Joined: 12/20/2009

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'

Offline
Joined: 10/14/2009
only.values

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!

Offline
Joined: 07/31/2009
The OpenMx functions are

The OpenMx functions are named eigenval, eigenvec, ieigenval, and ieigenvec. See ?eigenval.

Offline
Joined: 12/20/2009
Dear mspiegel, Just out of

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

Offline
Joined: 07/31/2009
Ah. So each matrix operator

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.

Offline
Joined: 07/30/2009
Unfortunately, not all

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.

Offline
Joined: 10/08/2009
Dear all, just to make sure I

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!

Offline
Joined: 07/31/2009
That is correct, an analogous

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.

Offline
Joined: 10/08/2009
thank you for your fast

thank you for your fast reply. March would be great - we are desperately looking forward to these functions!

Offline
Joined: 07/31/2009
As of OpenMx 0.3.0, the

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.

Offline
Joined: 07/31/2009
Yeah. This functionality is

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
Re(eigen(foo, only.values = TRUE)\$values)   # omxEigenRealVal?
and another that does
Re(eigen(foo)\$vectors)   # omxEigenRealVec?

Offline
Joined: 07/30/2009
That seems like a good

That seems like a good solution. Does that work for you, Han?

Offline
Joined: 12/20/2009
Steve and mspiegel, Could you

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

Offline
Joined: 07/31/2009
That sounds like a good idea

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.

Offline
Joined: 08/04/2009
eigen()

Is eigen() still on the list of things to do?

Offline
Joined: 07/31/2009
eigenvec, eigenval, ieigenvec, ieigenval

?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.

Offline
Joined: 08/04/2009
Thanks

Thanks! Sorry for the silly question --- I didn't see them under ?mxAlgebra, so I missed them.