Excellent analysis, Thomas. An alternative to looking at EISPACK documentation is to do the following computations:

(1) Values %*% diag(vectors) %*% solve(Values)

(2) solve(Values) %*% diag(vectors) %*% Values

One of these two should return the original matrix; the other will likely be very different. If so, the mystery is solved. If (1) returns
PA9900, then


PA9900 %*% Values = Values %*% diag(vectors)

Else

Values %*% PA9900 = diag(vectors) %*% Values

Best Wishes,
Spencer Graves

Thomas W Blackwell wrote:
Mikael -

The matrix PA9900 is not a symmetric matrix.  Eigen() will
automatically detect this.  help("eigen") says explicitly:

"For `eigen( , symmetric = FALSE)' the choice of length of
the eigenvectors is not defined by LINPACK.  In all other
cases the vectors are normalized to unit length."

In the example you give, the eigenvectors from R are clearly
NOT normalized to unit length, while those from Matlab are.
Even after normalizing them, the R eigenvectors will differ
by order and sign from the Matlab ones.  (Compare R column 3
with Matlab column 2.)  Have to look at the EISPACK source
documentation to see whether it's returning right eigenvectors
or left eigenvectors for an asymmetric matix.

- tom blackwell - u michigan medical school - ann arbor -

On Thu, 3 Apr 2003, Mikael Niva wrote:


Dear R-listers

Is there anyone who knows why I get different eigenvectors when I run
MatLab and R? I run both programs in Windows Me. Can I make R to produce
the same vectors as MatLab?

#R Matrix
PA9900<-c(11/24 ,10/53 ,0/1 ,0/1 ,29/43 ,1/24 ,27/53 ,0/1 ,0/1 ,13/43
,14/24 ,178/53 ,146/244 ,17/23 ,15/43 ,2/24 ,4/53 ,0/1 ,2/23 ,2/43 ,4/24
,58/53 ,26/244 ,0/1 ,5/43)

#R-syntax
PA9900<-matrix(PA9900,nrow=5,byrow=T)
eigen(PA9900)

#R-output
$values
[1]  1.2352970  0.3901522 -0.2562860  0.2259411  0.1742592

$vectors
           [,1]        [,2]        [,3]      [,4]       [,5]
[1,] -0.67795430 -1.70686496 -0.52613955 -8.675109 -0.8413826
[2,] -0.32621100  0.54611272 -0.21526356 -2.726193 -0.2876643
[3,] -2.83313878 -2.88801964  0.87388189 45.427935  4.5069361
[4,] -0.09857565 -0.33015962  0.09136359 -5.426254 -0.8201206
[5,] -0.68977432  0.01977374  0.61772506  3.751978  0.4348802

%Matlab Matrix
PA9900 =[11/24 10/53 0/1 0/1 29/43 ;1/24 27/53 0/1 0/1 13/43 ;14/24
178/53 146/244 17/23 15/43 ;2/24 4/53 0/1 2/23 2/43 ;4/24 58/53 26/244
0/1 5/43]

%MatLab-syntax
[wmat,dmat]=eig(mat)

%MatLab-output
wmat =
  -0.2250    0.4330   -0.4998   -0.1795   -0.1854
  -0.1083    0.1771    0.1599   -0.0614   -0.0583
  -0.9403   -0.7191   -0.8457    0.9617    0.9708
  -0.0327   -0.0752   -0.0967   -0.1750   -0.1160
  -0.2289   -0.5083    0.0058    0.0928    0.0802

dmat =
   1.2353         0         0         0         0
        0   -0.2563         0         0         0
        0         0    0.3902         0         0
        0         0         0    0.1743         0
        0         0         0         0    0.2259

Yours sincerely, Mikael Niva

********************************************
Mikael Niva
Avd. f?r V?xtekologi, Dept. of Plant Ecology
EvolutionsBiologiskt Centrum, Uppsala Universitet
Villav?gen 14
752 36 UPPSALA
E-post [EMAIL PROTECTED]
Tel. +46 (0)18 471 28 65
Fax +46 (0)18 55 34 19


______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help

Reply via email to