On Apr 21, 2012, at 19:13 , Berend Hasselman wrote: > > 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 >
They look quite similar to me: > ev <- eigen(solve(B,A) )$vectors > ge <- geigen(A, B, TRUE , TRUE) > ev / ge$vl [,1] [,2] [,3] [1,] 0.9324603 0.813422 -0.7423694 [2,] 0.9324603 0.813422 -0.7423694 [3,] 0.9324603 0.813422 -0.7423694 > ev / ge$vr [,1] [,2] [,3] [1,] 0.9324603 0.813422 -0.7423694 [2,] 0.9324603 0.813422 -0.7423694 [3,] 0.9324603 0.813422 -0.7423694 (and of course, eigenvectors of any sort are only defined up to a constant multiplier) -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd....@cbs.dk Priv: pda...@gmail.com ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.