[R] Matrix inversion

Ben Domingue ben.domingue at gmail.com
Tue Feb 19 04:05:53 CET 2008


Howdy,
I am trying to invert a matrix for the purposes of least squares.  I
have tried a number of things, and the variety of results has me
confused.
1. When I try solve() I get the following:
>Error in solve.default(t(X) %*% X) : system is computationally
singular: reciprocal condition number = 3.76391e-20
2. When I try qr.solve(), I get:
>Error in qr.solve(t(X) %*% X) : singular matrix 'a' in solve
3. I can, however, use lm(y~X) to get coefficients.  This confuses me
since I thought that lm() used qr().  So why did qr.solve() not work
earlier?
4. I have even tried using ginv().  The process works, but I end up
with a different set of regression coefficients after I finish the
process than what I had with lm().  To the best of my knowledge, this
shouldn't happen.

I've been digging around all day and can't figure this out.  Thanks,

Ben Domingue
PhD Student, School of Education
University of Colorado at Boulder



More information about the R-help mailing list