qr.coef(qr, y) qr.fitted(qr, y) qr.resid(qr, y) qr.qty(qr, y) qr.qy(qr, y) qr.solve(a, b, tol=1e-7)
qr
or
lsfit
.
x
matrix from which the decomposition
was computed.
qr.solve
only).
qr.solve
only).
a
when
a
is a matrix
(
qr.solve
only).
qr.coef
,
qr.fitted
and
qr.resid
return the coefficients,
the fitted values and the residuals that would be obtained by a least squares
fit of
y
to the
x
matrix from which
qr
was obtained.
qr.qy
and
qr.qty
return the results of the matrix multiplications:
Q %*% y
t(Q) %*% y
Conj(t(Q)) %*% y (in the complex case)
where
Q
is the order-
nrow(x)
orthogonal (or unitary) transformation
represented by
qr
.
qr.solve
returns the results of
solve.qr(a, b)
if
a
is a QR decomposition.
This is the least squares solution of
x h = b
where
a
is the QR decomposition of
x
.
If
a
is a matrix, the QR decomposition is computed first,
then
solve.qr
is called.
The results of
qr.coef
, etc.,
will reflect an intercept term, if included,
for example, in a call to
lm.fit.qr
.
The QR decomposition used does not return an explicit orthogonal (or unitary) matrix. For reasons of accuracy and efficiency, an indirect representation of the decomposition is used.
Dongarra, J. J., Bunch, J. R., Moler, C. B. and Stewart, G. W. (1979). LINPACK Users' Guide. SIAM, Philadelphia.
Thisted, R. A. (1988). Elements of Statistical Computing. Chapman and Hall, New York.
x <- cbind(1, runif(20), runif(20, 1, 10)) # X matrix with constant y <- x %*% c(2, 13.5, -0.7) + rnorm(20, 0, 0.2) reg0 <- lm.fit.qr(x, y, qr=TRUE) coef(reg0) qr.coef(reg0$qr, y) # same values as coef(reg0) qr.solve(x, y) # also same values as coef(reg0)