rose
rose

Reputation: 1981

Role of tol argument in QR decomposition

I am new user in R. Could you please tell me or introduce some refrences which describe the tol argument in calculating a QR decomposition in R?

For example what is the difference of this two lines:

qr(A, tol=1e-07) #Doesn't work

qr(A, tol=1e-20) #Works

Why do I get my desired resullt with such a small value of tol, but not with the bigger value?

Upvotes: 3

Views: 596

Answers (1)

IRTFM
IRTFM

Reputation: 263381

The tol argument controls whether qr will return a value or not for a column depending on whether the column has been judged to be linearly dependent. I would think that reducing the tol value below 1e-16 would be defeating the purpose of that check. (That's pretty much the pragmatic definition of zero in double precision math.)

First look at qr.default and then find the FORTRAN code:

http://svn.r-project.org/R/trunk/src/appl/dqrdc2.f

This is the comment from the FORTRAN routine that describes the logic:

c     cycle the columns from l to p left-to-right until one
c     with non-negligible norm is located.  a column is considered
c     to have become negligible if its norm has fallen below
c     tol times its original norm.  the check for l .le. k
c     avoids infinite cycling.

Upvotes: 5

Related Questions