# [R] NA in eigen()

Prof Brian Ripley ripley at stats.ox.ac.uk
Sat Mar 4 12:46:30 CET 2006

```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
>

--
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

2006/3/4, towsonu2003 at gmail.com <towsonu2003 at gmail.com>:
>
> Full_Name:
> Version: 2.1.1
> OS: Linux (Ubuntu 5.10)
> Submission from: (NULL) (136.160.174.71)
>
>
> R does not have a friendly gui from where all functions can be accessed by
>
> "point-and-click". Existing one I could try (tk) is too simple.
>
> The friendly gui should also include a spreadsheet-like data-viewer

fix(...)

as well as a
> data-output (exportable tables) and a graphics-output modules (the latter