How do I get the right eigenvectors of a matrix in R?
Edition: The problem in my question was that I tried to find the matrix S
from equation 8 but this equation has a bug.
How to directly get the direct eigenvectors of a matrix in R? 'eigen ()' gives only left eigenvectors
Indeed the latest edition , I made a big mess here, but this question is very important to me:
eigen()
provides some matrix of eigenvectors, from the help function:
"If 'r <are proper (A) and' V <- r $ vectors, lam <- r $ values, then
A = V Lmbd V^(-1)
(down to numerical fluff), where Lmbd =diag(lam)
"
that is A V = V Lmbd
, where V is a matrix , now we check it:
set.seed(1)
A<-matrix(rnorm(16),4,4)
Lmbd=diag(eigen(A)$values)
V=eigen(A)$vectors
A%*%V
> A%*%V
[,1] [,2] [,3] [,4]
[1,] 0.0479968+0.5065111i 0.0479968-0.5065111i 0.2000725+0i 0.30290103+0i
[2,] -0.2150354+1.1746298i -0.2150354-1.1746298i -0.4751152+0i -0.76691563+0i
[3,] -0.2536875-0.2877404i -0.2536875+0.2877404i 1.3564475+0i 0.27756026+0i
[4,] 0.9537141-0.0371259i 0.9537141+0.0371259i 0.3245555+0i -0.03050335+0i
> V%*%Lmbd
[,1] [,2] [,3] [,4]
[1,] 0.0479968+0.5065111i 0.0479968-0.5065111i 0.2000725+0i 0.30290103+0i
[2,] -0.2150354+1.1746298i -0.2150354-1.1746298i -0.4751152+0i -0.76691563+0i
[3,] -0.2536875-0.2877404i -0.2536875+0.2877404i 1.3564475+0i 0.27756026+0i
[4,] 0.9537141-0.0371259i 0.9537141+0.0371259i 0.3245555+0i -0.03050335+0i
and I would like to find the right eigenvector matrix R
, the
equation defining the left eigenvector matrix L
:
L A = LambdaM L
defining the matrix of right eigenvectors R
:
A R = LambdaM R
and eigen () only provides a matrix V
:
A V = V Lmbd
I would like to get a matrix R
, and LambdaM
for a real matrix A
, which can be negative definite.
source to share
Produced example.
Default (= correct eigenvectors):
m <- matrix(1:9,nrow=3)
e <- eigen(m)
e1 <- e$vectors
zapsmall((m %*% e1)/e1) ## right e'vec
## [,1] [,2] [,3]
## [1,] 16.11684 -1.116844 0
## [2,] 16.11684 -1.116844 0
## [3,] 16.11684 -1.116844 0
Left eigenvectors:
eL <- eigen(t(m))
eL1 <- eL$vectors
(We need to put in a little more effort since we need to multiply by the row vectors on the left; if we only extracted one eigenvector, the ignorance of the vector differences between rows and columns is "do the right thing" (ie, it (eL1[,1] %*% m)/eL1[,1]
just works).)
zapsmall(t(eL1) %*% m/(t(eL1)))
## [,1] [,2] [,3]
## [1,] 16.116844 16.116844 16.116844
## [2,] -1.116844 -1.116844 -1.116844
## [3,] 0.000000 0.000000 0.000000
source to share