[R] find the eigenvector corresponding to the largest eigenvalue
Berend Hasselman
bhh at xs4all.nl
Fri Apr 27 19:25:03 CEST 2012
On 27-04-2012, at 17:41, Rebecca wrote:
> Hi,
> If I use the eigen() function to find the eigenvalues of a matrix, how can I find the eigenvector corresponding to the largest eigen value?
What does the documentation of eigen() say in the Value section for values?
Sorted in decreasing order.
So the first item of ..$values is the largest eigenvalue and thus the first column of ..$vectors is the corresponding eigenvector.
Example
n <- 3
A <- matrix(round(runif(n*n),2),nrow=n)
A
evv.A <- eigen(A)
evv.A
k <- which(abs(evv.A$values)==max(abs(evv.A$values)))
evv.A$vectors[,k]
k
Berend
More information about the R-help
mailing list