TITLE(qr @@ The QR Decomposition of a Matrix)
USAGE(
qr(x, tol=1e-07)
qr.coef(qr, y)
qr.qy(qr, y)
qr.qty(qr, y)
qr.resid(qr, y)
qr.fitted(qr, y, k=qr$rank)
qr.solve(a, b, tol=1e-7)
is.qr(x)
as.qr(x)
)
ALIAS(qr)
ALIAS(qr.coef)
ALIAS(qr.qy)
ALIAS(qr.qty)
ALIAS(qr.resid)
ALIAS(qr.fitted)
ALIAS(qr.solve)
ALIAS(is.qr)
ALIAS(as.qr)
ARGUMENTS(
ARG(x @@ a matrix whose QR decomposition is to be computed.)
ARG(tol @@ the tolerance for detecting linear dependencies in
the columns of LANG(x).)
ARG(qr @@ a QR decomposition of the type computed by LANG(qr).)
ARG(y @@ a vector or matrix of right-hand sides of equations.)
)
DESCRIPTION(
LANG(qr) provides an interface to the techniques used in the LINPACK
routine DQRDC.
The QR decomposition plays an important role in many statistical
techniques.
In particular it can be used to solve the equation
EQN(EQBOLD(Ax) EQUALS EQBOLD(b)) for given matrix EQN(EQBOLD(A)),
and vector EQN(EQBOLD(b)).
It is useful for computing regression coefficients and in applying the
Newton-Raphson algorithm.
PARA
The functions LANG(qr.coef), LANG(qr.qy), LANG(qr.qty),
LANG(qr.resid), and LANG(qr.fitted) use a computed
QR decomposition to compute various quantities of interest.
PARA
LANG(qr.solve) solves systems of equations via the QR decomposition.
PARA
LANG(is.qr) returns LANG(TRUE) if LANG(x) is a list with a
component named LANG(qr) and LANG(FALSE) otherwise.
PARA
It is not possible to coerce objects to mode qr.
Objects either are qr decompositions or they are not. 
Coercion is not possible.
)
VALUES(
The QR decomposition of the matrix as computed by LINPACK.
The components in the returned value correspond directly
to the values returned by DQRDC. @@
ARG(qr @@ a matrix with the same dimensions as LANG(x).
The upper triangle contains the BOLD(R) of the decomposition
and the lower triangle contains information on the BOLD(Q)
of the decomposition (stored in compact form).)
ARG(qraux @@ a vector of length LANG(ncol(x)) which contains
additional information on BOLD(Q).)
ARG(rank @@ the rank of LANG(x) as computed by the decomposition.)
ARG(pivot @@ information on the pivoting strategy used during
the decomposition.)
)
REFERENCES(
Dongarra, J. J., J. R. Bunch, C. B. Moler and G. W. Stewart (1978).
ITALIC(LINPACK Users Guide), SIAM Publications, Philadelphia.
)
SEEALSO(
LANG(LINK(solve.qr)), LANG(LINK(lsfit)).
)
EXAMPLES(
hilbert <- function(n) { i <- 1:n; 1/outer(i-1,i,"+") }
h9 <- hilbert(9); h9
qr(h9)$rank           ##--> only 7
qrh9 <- qr(h9, tol=1e-10)
qrh9$rank             ##--> 9
##-- Solve linear equation system  H %*% x = y :
y <- 1:9/10
x <- qr.solve(h9, y, tol = 1e-10) ## or equivalently :
x <- qr.coef(qrh9, y) ##-- is == but much better than
                      ##-- solve(h9) %*% y
h9 %*% x              ## = y
)
