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.
Hello Wang matrix bb is symmetric positive semidefinite, so algebraically the eigenvalues are nonnegative. I would use bb <- crossprod(b) to calculate bb (faster and possibly more accurate) Look at eigen(bb,TRUE,TRUE)$values (see ?eigen for the meaning of the arguments) to see how many very small eigenvalues you have. The number of zero eigenvalues is equal to the number of linear relations in the columns of b. HTH rksh On 12 Dec 2007, at 10:59, 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. > ______________________________________________ > 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.-- Robin Hankin Uncertainty Analyst and Neutral Theorist, National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743
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
Maybe Matching Threads
- eigenvalues and correlation matrices
- How to circumvent negative eigenvalues in the capscale function
- Problem with a domain controller that is located in a separate site
- Problem with a domain controller that is located in a separate site
- nearest correlation to polychoric