[R] Eigenvectors and values in R and SAS

Juliet Hannah juliet.hannah at gmail.com
Fri Jan 15 22:18:11 CET 2010


Here is an example that may be helpful.

A <- matrix(c(-3,5,4,-2),nrow=2,byrow=TRUE)
eigs <- eigen(A)

eigs

$values
[1] -7  2

$vectors
           [,1]       [,2]
[1,] -0.7808688 -0.7071068
[2,]  0.6246950 -0.7071068

The eigenvectors may be scaled differently because they are not unique
(or have a different sign), but Ax = lambda x, for an eigenvalue
lambda.

#Ax
A %*% eigs$vectors[,1]

          [,1]
[1,]  5.466082
[2,] -4.372865

# λx
> -7 * eigs$vectors[,1,drop=FALSE]
          [,1]
[1,]  5.466082
[2,] -4.372865


The eigenvectors for proc iml are scaled similarly, but have different signs.

proc iml;
A = {-3 5, 4 -2};
print A;
eigval = eigval(A);
evec = eigvec(A);
print eigval;
print evec;

A_x = A*evec[,1];
lambda_x = eigval[1,1]*evec[,1];
print A_x;
print lambda_x;

quit;



More information about the R-help mailing list