[R] Solve an ordinary or generalized eigenvalue problem in R?

Berend Hasselman bhh at xs4all.nl
Sun Apr 22 21:27:23 CEST 2012


On 22-04-2012, at 21:08, Jonathan Greenberg wrote:

> Thanks all (particularly to you, Berend) -- I'll push forward with these solutions and integrate them into my code.  I did come across geigen while rooting around in the CCA code but its not formally documented (it just says "for internal use" or something along those lines) and as you found out above, it does not produce the same solution as the dggev.  It would be nice to have a more complete set of formal packages for doing LA in R (rather than having to hand-write .Fortran calls) but I'll leave that to someone with more expertise in linear algebra than me.  Something that perhaps matches the SciPy set of functions (both in terms of input and output):
> 
> http://docs.scipy.org/doc/scipy/reference/linalg.html
> 
> Some of these are already implemented, but clearly not all of them.  

Package CCA has package fda as dependency.
And package fda defines a function geigen.
The first 14 lines of this function are

geigen <- function(Amat, Bmat, Cmat)
{
  #  solve the generalized eigenanalysis problem
  #
  #    max {tr L'AM / sqrt[tr L'BL tr M'CM] w.r.t. L and M
  #
  #  Arguments:
  #  AMAT ... p by q matrix
  #  BMAT ... order p symmetric positive definite matrix
  #  CMAT ... order q symmetric positive definite matrix
  #  Returns:
  #  VALUES ... vector of length s = min(p,q) of eigenvalues
  #  LMAT   ... p by s matrix L
  #  MMAT   ... q by s matrix M

It's not clear to me how it is used and exactly what it is doing and how that compares with Lapack.

Berend



More information about the R-help mailing list