# Re: [R] singular matrix

From: <Bill.Venables_at_csiro.au>
Date: Tue 29 Aug 2006 - 13:36:10 EST

Nongluck Klibbua reports:

> -----Original Message-----

> From: r-help-bounces@stat.math.ethz.ch
> [mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of Nongluck
> Klibbua
> Sent: Tuesday, 29 August 2006 11:12 AM
> To: R-help@stat.math.ethz.ch
> Subject: [R] singular matrix
>
> 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

The irony seems to be that if you quote them to only this number of digits then the system is no longer quite singular enough for the problem to appear, at least on Windows R 2.3.1:

> a

[,1]
[1,] 0.8109437
[2,] 5.7569740
> b

[,1] [,2]
[1,] 0.3141293 2.230037
[2,] 2.2300367 15.831264
> solve(b, a)

[,1]
[1,] 2.5831242104
[2,] -0.0002203103
> b %*% solve(b, a) - a ### check

[,1]
[1,] -1.110223e-16
[2,] -8.881784e-16

In general, though, in dealing with singular systems you might want to look at the function ginv in the MASS library.

R-help@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. Received on Tue Aug 29 13:40:36 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 29 Aug 2006 - 16:27:42 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.