qtyr#
Purpose#
Computes the orthogonal-triangular (QR) decomposition of a matrix
Format#
- { qty, r } = qtyr(y, X)#
- Parameters:
y (NxL matrix) – data
X (NxP matrix) – data
- Returns:
qty (NxL matrix) – unitary matrix
r (KxP matrix) – upper triangular matrix.
.
Examples#
The QR algorithm is the numerically superior method for the solution of least squares problems:
loadm x, y;
{ qty, r } = qtyr(y, x);
q1ty = qty[1:rows(r), .];
q2ty = qty[rows(r)+1:rows(qty), .];
// LS coefficients
b = qrsol(q1ty, r);
// Residual sums of squares
s2 = sumc(q2ty^2);
Remarks#
Given
where
where
is the QR decomposition of qyr()
). Since qtyr()
has
been provided for the calculation of
and
Suppose that
and
where b is a PxL matrix of least squares coefficients and s is a 1xL
vector of residual sums of squares. Rather than invert qrsol()
to
For rank deficient least squares problems, see qtyre()
and qtyrep()
.
Source#
qtyr.src