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
Nongluck Klibbua reports:> -----Original Message-----> From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Nongluck > Klibbua > Sent: Tuesday, 29 August 2006 11:12 AM > To: R-help at 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 haserror> 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-018The 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.
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. >