R-alpha: eigen()

Peter Dalgaard BSA p.dalgaard@kubism.ku.dk
01 May 1997 22:28:56 +0200


eigen() seems to work for symmetric matrices only. This is out of sync
with the help file.

> trpr.37
           0         1         2         3         4
0 1.00000000 0.0000000 0.0000000 0.0000000 0.0000000
1 0.44444444 0.5555556 0.0000000 0.0000000 0.0000000
2 0.02439024 0.2439024 0.7317073 0.0000000 0.0000000
3 0.00000000 0.0000000 0.2307692 0.7692308 0.0000000
4 0.00000000 0.0000000 0.0000000 0.3636364 0.6363636
> eigen(trpr.37)
$values
[1] 0.1760338 0.3173947 0.7351695 1.1361504 1.3281087

$vectors
           [,1]        [,2]       [,3]       [,4]      [,5]
[1,] -0.3707705 -0.27063913 -0.3559571  0.3273765 0.7452536
[2,]  0.7110188  0.41060304  0.1696518  0.1176558 0.5321961
[3,] -0.4307468  0.09222746  0.7735674 -0.3164802 0.3276966
[4,]  0.3249070 -0.57094755 -0.1300796 -0.7136115 0.2056509
[5,] -0.2566594  0.65090138 -0.4787334 -0.5192116 0.1081065

--Huh? 0,0,0,0,1 should be an eigenvector with e.v. 0.6363636.

> eigen(t(trpr.37))
$values
[1] 0.5555556 0.6363636 0.7317073 0.7692308 1.0000000

$vectors
     [,1] [,2] [,3] [,4] [,5]
[1,]    0    0    0    0    1
[2,]    1    0    0    0    0
[3,]    0    0    1    0    0
[4,]    0    0    0    1    0
[5,]    0    1    0    0    0

-- Doesn't look right, check:

> t(trpr.37)%*%eigen(t(trpr.37))$vectors
       [,1]      [,2]       [,3]      [,4] [,5]
0 0.4444444 0.0000000 0.02439024 0.0000000    1
1 0.5555556 0.0000000 0.24390244 0.0000000    0
2 0.0000000 0.0000000 0.73170732 0.2307692    0
3 0.0000000 0.3636364 0.00000000 0.7692308    0
4 0.0000000 0.6363636 0.00000000 0.0000000    0

-- which is obviously not proportional to the "eigenvectors". What
happens is that the matrices get symmetrified by duplicating the lower
triangle onto the upper one.

BTW. Who was it who talked about matrix exponentials a while back? I
could use such code now...

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-