[R] NA in eigen()

Spencer Graves spencer.graves at pdf.com
Tue Mar 7 04:02:31 CET 2006


	  I didn't see a reply to your latest question:

	  Are you familiar with "sessionInfo()"?  This is designed to provide a 
brief summary of your installation, attached packages, etc.

	  Beyond this, from Prof. Ripley's reply (below), you might consider 
writing a wrapper function with a name like "eigen." or "eigenSym" that 
might call eigen with the default LAPACK option and try EISPACK only if 
you have NAs as eigenvalues -- or call both, do some comparison, and act 
accordingly.

	  hope this helps.
	  spencer graves

Elizabeth Purdom wrote:

> Sorry, I forgot to give my system details. I am using R 2.2.1 on a Windows 
> XP. I just did the standard download from the CRAN page for Windows. I did 
> not use any special options. I don't know what compilation the download is, 
> the details of BLAS or LAPACK for my computer, etc. -- how can I find this 
> information for my computer?
> Thanks,
> Elizabeth
> 
> 
> At 03:46 AM 3/4/2006, Prof Brian Ripley wrote:
> 
>>The default is to use LAPACK rather than EISPACK.  In general, LAPACK is a 
>>lot faster and a lot stabler than EISPACK, so you will get `odd behavior' 
>>much more often with EISPACK=TRUE (sic).
>>
>>You have not told us your machine or R details.  Most of the problem 
>>reports we see in this area are not due to R itself but to a problem in 
>>the BLAS or LAPACK in use on the system running R.  So exactly what system 
>>is this, how was R compiled and with what options?
>>
>>On Fri, 3 Mar 2006, Elizabeth Purdom wrote:
>>
>>
>>>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,
>>
>>NAs and not NaNs?  I don't think the internal code of eigen knows how to 
>>generate NAs, and is.na is not a test for NAs.
>>
>>
>>>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
>>>
>>>______________________________________________
>>>R-help at stat.math.ethz.ch mailing list
>>>https://stat.ethz.ch/mailman/listinfo/r-help
>>>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>>
>>--
>>Brian D. Ripley,                  ripley at stats.ox.ac.uk
>>Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
>>University of Oxford,             Tel:  +44 1865 272861 (self)
>>1 South Parks Road,                     +44 1865 272866 (PA)
>>Oxford OX1 3TG, UK                Fax:  +44 1865 272595
> 
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html




More information about the R-help mailing list