NA in eigen()

Elizabeth Purdom epurdom at stanford.edu
Fri Mar 3 21:41:53 CET 2006


Hi,
I am using eigen to get an eigen decomposition of a square, symmetric 
matrix. For some reason, I am getting a column in my eigen vectors (the 
52nd column out of 601) that is a column of all NAs. I am using the option, 
symmetric=T for eigen. I just discovered that I do not get this behavior 
when I use the option EISPACK=T. With EISPACK=T, the 52nd eigenvector is 
(up to rounding error) a vector of all zeros except for  -0.6714 
and  +0.6714 in two locations. The eigenvalues (which are the same with 
either one) has the 52nd eigenvalue being exactly 19. I also do not have 
the NA problem if I choose symmetric=F.

My main question is whether there is any reason I should not use the 
EISPACK option (I do not know that what the EISPACK option really means, 
except that its not "preferred")? Or stated another way, should I trust 
that the results for EISPACK=T, and just ignore the very odd behavior of 
EISPACK=F? Or is there something inherently problematic or unstable about 
my eigen decomposition of this matrix -- and if so, is it my matrix or the 
program?

I have no idea what's causing it, and I can't get a reproducible example, 
other than with my large matrix. My original matrix has no NAs in it. Here 
is code, but of course it requires my original, 601x601 symmetric matrix 
called mat

 > any(is.na(mat))
[1] FALSE
 > any(is.na(d))
[1] FALSE
 > dim(mat)
[1] 601 601
 > length(which(d==0))
[1] 5
 > d<-rowSums(mat)
 > temp1<-eigen(diag(d)-mat,symmetric=T)
 > temp2<-eigen(diag(d)-mat,symmetric=T,EISPACK=T)
 > any(is.na(temp1$vec))
[1] TRUE
 > any(is.na(temp1$vec[,-52]))
[1] FALSE
 > any(is.na(temp2$vec))
[1] FALSE
 > all.equal(abs(temp1$vec[,-52]),abs(temp2$vec[,-52]))
[1] "Mean relative  difference: 0.3278133"
 > all.equal(temp1$val,temp2$val)
[1] TRUE
 > temp2$val[52]
[1] 19

Thanks,
Elizabeth



More information about the R-help mailing list