Reconstruct the Q, R, or X Matrices from a QR Object

DESCRIPTION:
Returns the original matrix from which the object was constructed.

USAGE:
qr.X(qrstr, complete=F, ncol=)
qr.Q(qrstr, complete=F, Dvec=1)
qr.R(qrstr, complete=F)

REQUIRED ARGUMENTS:
qrstr:
object representing a QR decomposition. This will typically have come from a previous call to qr or lsfit.

OPTIONAL ARGUMENTS:
complete:
logical expression of length 1. Indicates whether an arbitrary orthogonal completion of the Q or X matrices is to be made, or whether the R matrix is to be completed by binding zero-value rows beneath the square upper triangle.
ncol:
integer in the range 1:nrow(qrstr$qr). The number of columns to be in the reconstructed X. The default when complete==F is the original X from which the qr object was constructed. The default when complete==T is a square matrix with the original X in the first ncol(X) columns and an arbitrary orthogonal completion (unitary completion in the complex case) in the remaining columns.
Dvec:
vector (not matrix) of diagonal values. Each column of the returned Q will be multiplied by the corresponding diagonal value.

VALUE:
qr.X returns X, the original matrix from which the qr object was constructed. If complete==T 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 qrstr. If complete==T, Q has nrow(X) columns. If complete==F, 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 c(ncol(X),ncol(X)) upper triangular matrix such that X == Q %*% R. If complete==T, R has nrow(X) rows. If complete==F, R has ncol(X) rows. qr.


SEE ALSO:
qr , qr.qy .

EXAMPLES:
qrstr <- qr(x)        # dim(x) == c(n,p)
Q <- qr.Q(qrstr) # dim(Q) == dim(x)
R <- qr.R(qrstr) # dim(R) == ncol(x)
X <- qr.X(qrstr) # X == x
# X == Q %*% R
Qc <- qr.Q(qrstr, complete=T) # dim(Qc) == nrow(x)
QD <- qr.Q(qrstr, D=seq(p))   # QD == Q %*% diag(D)
Rc <- qr.R(qrstr, complete=T) # dim(Rc) == dim(x)
Xc <- qr.X(qrstr, complete=T) # Xc[,seq(p)]==x ; dim(Xc)==nrow(x)