Hi, I was wondering if function eigen() does something different from the function call eigen() in SAS. I'm in the process of translating a SAS code into a R code and the values of the eigenvectors and eigenvalues of a square matrix came out to be different from the values in SAS. I would also appreciate it if someone can explain the difference in simple terms. I'm pretty new to both programs. Thanks for your help- -- View this message in context: http://n4.nabble.com/Eigenvectors-and-values-in-R-and-SAS-tp1011510p1011510.html Sent from the R help mailing list archive at Nabble.com.
On 12/01/2010, at 8:31 AM, jso717 wrote:> > Hi, > > I was wondering if function eigen() does something different from the > function call eigen() in SAS. > I'm in the process of translating a SAS code into a R code and the > values of > the eigenvectors and eigenvalues of a square matrix came out to be > different > from the values in SAS. > I would also appreciate it if someone can explain the difference in > simple > terms. I'm pretty new to both programs. Thanks for your help-Read the posting guide then repost your question. cheers, Rolf Turner ###################################################################### Attention:\ This e-mail message is privileged and confid...{{dropped:9}}
On Jan 11, 2010, at 2:31 PM, jso717 wrote:> > Hi, > > I was wondering if function eigen() does something different from the > function call eigen() in SAS. > I'm in the process of translating a SAS code into a R code and the > values of > the eigenvectors and eigenvalues of a square matrix came out to be > different > from the values in SAS.Examples? Were you under the impression that eigenvectors and eigenvalues were uniquely determined? You should review your matrix algebra. The question should be whether they are the same (still modulo sign) after normalization.> I would also appreciate it if someone can explain the difference in > simple > terms. I'm pretty new to both programs. Thanks for your help- > --David Winsemius, MD Heritage Laboratories West Hartford, CT
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;