QR.Auxiliaries {base} | R Documentation |
Returns the original matrix from which the object was constructed or the components of the decomposition.
qr.X(qr, complete = FALSE, ncol =)
qr.Q(qr, complete = FALSE, Dvec = 1)
qr.R(qr, complete = FALSE)
qr |
object representing a QR decomposition. This will
typically have come from a previous call to |
complete |
logical expression of length 1. Indicates whether an
arbitrary orthogonal completion of the |
ncol |
integer in the range |
Dvec |
vector (not matrix) of diagonal values. Each column of
the returned |
qr.X
returns \bold{X}
, the original matrix from
which the qr object was constructed, provided ncol(X) <= nrow(X)
.
If complete
is TRUE
or the argument ncol
is greater than
ncol(X)
, additional columns from an arbitrary orthogonal
(unitary) completion of X
are returned.
qr.Q
returns Q, the order-nrow(X) orthogonal (unitary)
transformation represented by qr
. If complete
is
TRUE
, Q has nrow(X)
columns. If complete
is FALSE
, Q has ncol(X)
columns. When
Dvec
is specified, each column of Q is multiplied by the
corresponding value in Dvec
.
qr.R
returns R, the upper triangular matrix such that
X == Q %*% R
. The number of rows of R is
nrow(X)
or ncol(X)
, depending on whether complete
is TRUE
or FALSE
.
qr
,
qr.qy
.
data(LifeCycleSavings)
p <- ncol(x <- LifeCycleSavings[,-1]) # not the `sr'
qrstr <- qr(x) # dim(x) == c(n,p)
qrstr $ rank # = 4 = p
Q <- qr.Q(qrstr) # dim(Q) == dim(x)
R <- qr.R(qrstr) # dim(R) == ncol(x)
X <- qr.X(qrstr) # X == x
range(X - as.matrix(x))# ~ < 6e-12
## X == Q %*% R :
Q %*% R