On Wed, 27 Feb 2002, Chunlei KE wrote:
> Dear Splus-users,
>
> I tried to use eigen() to calculate eigen values for a symetric matrix,
> and came across the following:
>
> >is.matrix(mat)
> [1] T
> >dim(mat)
> [1] 252 252
> >summary(mat)
> Min. 1st Qu. Median Mean 3rd Qu. Max.
> -0.25 -0.25 -0.25 0.00154 0.75 0.75
>
> >eigen(mat)$value
> [1] NA NA NA NA 6.795e+001
> 1.612e-014 2.572e-016 ... ...
>
> These NA's are wrong. But eigen.Matrix gives the
> correct answer:
>
> >Re(eigen.Matrix(mat)$value) # imaginary part is very small
> [1] 6.300e+001 6.795e+001 5.805e+001 2.654e-016 2.654e-016
> 1.900e-015 ...
Is this then a non-symmetric matrix with 3 non-zero real eigenvalues?
It really is asking rather a lot of an eigenvalue routine to cope with a
252-dimensional matrix with that degree of numerical singularity,
and unusual to have some much structure and not exploit it.
> I am using Splus 2000 on NT. I tried on unix (Splus 3.4) and it has no
> problem, either.
`unix' isn't very precise: this sort of thing depends on the compiler
and the run-time libraries. Different Unices often give different answers.
> Can someone please tell me what happened to these NAs? Is there any
> way to go around(in this example, those NAs are 0's indeed)?
I think you have already used it: eigen.Matrix is based on LAPACK and is a
better algorithm than that underlying eigen. Unfortunately the current
version of S-PLUS for Windows does not have library(Matrix). Often an even
better alternative is to use the SVD and not the eigendecomposition: but
that depends on the problem.
--
Brian D. Ripley, ripley@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 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
|