[R] singular matrix

Gabor Grothendieck ggrothendieck at gmail.com
Tue Aug 29 05:39:02 CEST 2006


b is nearly singular.  Note that one of its eigenvalues is -2.935e-8
which is close to zero.  We can use the generalized inverse from
MASS to get one solution, x, but any multiple of the eigenvector
corresponding to the near-zero eigenvalue when added to that
will also give a solution as shown:

> eigen(b)
$values
[1]  1.614539e+01 -2.935343e-08

$vectors
           [,1]       [,2]
[1,] -0.1394858 -0.9902241
[2,] -0.9902241  0.1394858

> library(MASS)
> x <- ginv(b) %*% a
> a
[1] 0.8109437 5.7569740
> # bx gives a showing x is a solution
> b %*% x
          [,1]
[1,] 0.8109438
[2,] 5.7569740
> # but b(x + e) where e is 2nd eigenvector is also solution
> b %*% (x + eigen(b)$vectors[,2])
          [,1]
[1,] 0.8109438
[2,] 5.7569740

On 8/28/06, Nongluck Klibbua <Nongluck.Klibbua at newcastle.edu.au> wrote:
> Dear R-users,
> I try to use "solve" to get the solution of this matrix.But it has error
> happen below.
> How  I can solve this problem.
> [1] "a"
>          [,1]
> [1,] 0.8109437
> [2,] 5.7569740
> [1] "b"
>          [,1]      [,2]
> [1,] 0.3141293  2.230037
> [2,] 2.2300367 15.831264
>
> Error in solve.default(b, a) : system is computationally singular:
> reciprocal condition number = 1.37415e-018
>
> Thanks
> Luck
>
> ______________________________________________
> 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
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list