# Re: R-alpha: qr

Douglas Bates (bates@stat.wisc.edu)
Wed, 18 Sep 96 14:35 CDT

```Message-Id: <m0v3SPL-0000TuC@franz.stat.wisc.edu>
Date: Wed, 18 Sep 96 14:35 CDT
From: Douglas Bates <bates@stat.wisc.edu>
To: Thomas Lumley <thomas@biostat.washington.edu>
Subject: Re: R-alpha: qr
<Pine.SUN.3.91.960918101443.1823D-100000@zen>

>>>>> "Thomas" == Thomas Lumley <thomas@biostat.washington.edu> writes:

Thomas> R does not have the functions qr.R() and qr.Q() for
Thomas> extracting components of a qr decomposition.  Are these easy
Thomas> to provide?

Yes, they are easy to provide.  In fact, it is difficult to describe
the algorithm without writing down the S function that gives the
result.

qr.R takes the "qr" component of the result of qr and zeros out the
elements below the diagonal.  If you want the "complete" R, it has the
same dimensions as the qr component which is itself a matrix.  If you
don't want the complete R, you take the upper left square matrix.  In
most cases this means dropping some rows because the number of rows
exceeds the number of columns.

For qr.Q, you multiply Q by a subset of the columns of an identity
matrix.  The function qr.qy performs the multiplication implicitly.

The qr component of the qr-structure contains R in the upper triangle
and, in the strict lower triangle, information used to generate the
contained in the section of the Linpack manual dealing with the QR
decomposition.

Generally there are good reasons for wanting R explicitly.  It is less
common to want to get Q explicitly.  For example, it is not a good
idea to produce Q simply to get Qy or Q'y.  That is accomplished more
effectively by the qr.qy and qr.qty functions.  If you wanted to get
the hat matrix or its diagonal, however, it might be a good idea to
produce Q along the way.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-testers mailing list -- To (un)subscribe, send
subscribe	or	unsubscribe
(in the "body", not the subject !)  To: r-testers-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
```