-3

Example: I have 20 eigen values and i have chosen 10 as best eigen values. For these 10 values I need to find eigen vectors seperately.How to do? I am new to R programming. Expecting your reply.

1 Answers1

1
> B <- matrix(1:4, 2)
> eig <- eigen(B)
> eig$vectors[,which.max(eig$values)]
[1] -0.5657675 -0.8245648

or something like this

> n <- 3 
> A  <- matrix(round(runif(n*n),2),nrow=n) 
> A 
     [,1] [,2] [,3]
[1,] 0.54 0.90 0.82
[2,] 0.09 0.42 0.95
[3,] 0.17 0.75 0.69
> evv.A <- eigen(A) 
> evv.A 
$values
[1]  1.6230202  0.3095823 -0.2826025

$vectors
           [,1]        [,2]       [,3]
[1,] -0.7455955 -0.97996498  0.3069212
[2,] -0.4464598  0.18600090 -0.7788676
[3,] -0.4947332  0.07122006  0.5469594

> 
> k <- which(abs(evv.A$values)==max(abs(evv.A$values))) 
> evv.A$vectors[,k] 
[1] -0.7455955 -0.4464598 -0.4947332
> k 
[1] 1
Prasanna Nandakumar
  • 4,295
  • 34
  • 63
  • Thanks for your reply. your 2nd suggestion takes the first largest eigen value among the values and displaying its eigen vector. As per your example, I need to select two eigenvalues 1.6230202 0.3095823 and must display its eigen vector. Any methods for doing it?? – Revathi shankar Oct 11 '14 at 04:58
  • Do this `k <- 1:2` and then the statement `evv.A$vectors[,k]` should give what you want as a matrix. Read the help for eigen with `?eigen`. – Bhas Oct 11 '14 at 05:32