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

Berend Hasselman bhh at xs4all.nl
Sat Apr 21 19:13:18 CEST 2012


On 21-04-2012, at 16:40, peter dalgaard wrote:

> 
> On Apr 21, 2012, at 15:22 , Luke Hartigan wrote:
> 
>> Hi all,
>> 
>> In my experience, using eigen to solve generalized eigenvalue / eigenvector
>> problems only gives correct looking eigenvalues while the eigenvectors seem
>> to be wrong (in comparison to results from MATLAB's 'eig' function for
>> example).
> 
> Could you please document that? There are many misconceptions about when eigenvectors are "correct" and platform dependencies too. As far as I can tell, both R and Matlab use the same LAPACK routines.


The OP posted two matrices:

A <- matrix(c(1457.738, 1053.181, 1256.953,
              1053.181, 1213.728, 1302.838,
              1256.953, 1302.838, 1428.269), nrow=3, byrow=TRUE)

B <- matrix(c(4806.033, 1767.480, 2622.744,
              1767.480, 3353.603, 3259.680,
              2622.744, 3259.680, 3476.790), nrow=3, byrow=TRUE)

I've tried

eigen(solve(B)%*%A) 

(which is probably not the best way to handle this problem numerically) to approximate the generalized ev problem.
And the geigen function

geigen(A,B,TRUE,TRUE)

The eigenvalues are identical upto the printed 9 digits but the eigenvectors appear to be quite different.
Maybe this is what Luke meant.

Berend



More information about the R-help mailing list