Re: [R] Matrix Inversion

From: Peter Dalgaard <P.Dalgaard_at_biostat.ku.dk>
Date: Wed, 12 Dec 2007 12:22:18 +0100

Wang Chengbin wrote:
> I got the following error:
>
> a = read.csv("mat.csv")
> b = as.matrix(a)
> tb = t(b)
> bb = tb %*% b
> dim(bb)
> ibb = solve(bb)
> bb %*% ibb
>
>
>> ibb = solve(bb)
>>
> Error in solve.default(bb) :
> system is computationally singular: reciprocal condition number =
> 1.77573e-19
>
> Are there any ways to find more information about why it is singular?
>
> Thanks.
>
Yes. Since the matrix is positive semidefinite by construction, I'd probably go for chol(bb, pivot=TRUE), then the first "rank" elements of "pivot" gives you a maximal subset of linearly independent columns, and you can proceed by something like lm(b[,-subset]~b[,subset]) to see what the linear dependencies are.

(Other approaches could be eigen() and svd().)

-- 
   O__  ---- Peter Dalgaard             Ă˜ster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard_at_biostat.ku.dk)                  FAX: (+45) 35327907

______________________________________________
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 Wed 12 Dec 2007 - 11:27:48 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 Wed 12 Dec 2007 - 11:30:18 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.