# Re: [R] matrix inverstion

From: Petr Savicky <savicky_at_praha1.ff.cuni.cz>
Date: Tue, 29 Mar 2011 10:38:45 +0200

On Mon, Mar 28, 2011 at 04:51:00PM +0200, Rosario Garcia Gil wrote:
> Hello
>
> I have this matrix which I am trying to invert. I get a message about reciprocal condition number, what that does mean?
>
> > XT_X
> [,1] [,2] [,3] [,4] [,5]
> [1,] 3 0 0 2 1
> [2,] 0 2 0 1 1
> [3,] 0 0 2 1 1
> [4,] 2 1 1 4 0
> [5,] 1 1 1 0 3
> > iXT_X <- solve(XT_X)
> Error in solve.default(XT_X) :
> system is computationally singular: reciprocal condition number = 1.11022e-17

This matrix is exactly singular. For example, the sum of the first three rows is equal to the sum of the last two.

cbind(1, 1, 1, -1, -1) %*% XT_X

[,1] [,2] [,3] [,4] [,5]
[1,] 0 0 0 0 0

For matrices with small integer entries, a test for singularity may be done using det().

det(XT_X)

[1] 8.881784e-15

Since the exact determinant is an integer, it has to be zero and the difference from zero is due to rounding error.

Hope this helps.

Petr Savicky.

R-help_at_r-project.org 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 29 Mar 2011 - 08:42:23 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 29 Mar 2011 - 08:50:25 GMT.

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