qtyre#
Purpose#
Computes the orthogonal-triangular (QR) decomposition of a matrix X and returns \(Q'Y\) and \(R\).
Format#
- { qty, r, e } = qtyre(y, x)#
- Parameters:
y (NxL matrix) – data
x (NxP matrix) – data
- Returns:
qty (NxL matrix) – unitary matrix
r (KxP matrix) – upper triangular matrix. \(K = min(N,P)\).
e (Px1 vector) – permutation vector
Remarks#
Given \(X[., E]\), where \(E\) is a permutation vector that permutes the columns of \(X\), there is an orthogonal matrix \(Q\) such that \(Q'X[., E]\) is zero below its diagonal, i.e.,
where \(R\) is upper triangular. If we partition
where \(Q_1\) has \(P\) columns, then
is the QR decomposition of \(X[., E]\).
If \(X\) has rank \(P\), then the columns of \(X\) will not be permuted. If \(X\) has rank \(M < P\), then the \(M\) linearly independent columns are permuted to the front of \(X\) by \(E\). Partition the permuted \(X\) in the following way:
where \(X_1\) is NxM and \(X_2\) is \(N \times (P-M)\). Further partition \(R\) in the following way:
where \(R_{11}\) is MxM and \(R_{12}\) is \(M \times (P-M)\). Then
and
that is, \(A\) is an \(M \times (P-N)\) matrix defining the linear combinations of \(X_2\) with respect to \(X_1\).
For most problems \(Q\) or \(Q_1\) is not it is required. Rather, we require
\(Q'Y\) or \(Q_1'Y\) where \(Y\) is an NxL matrix. Since \(Q\) can be a very large
matrix, qtyre()
has been provided for the calculation of \(Q'Y\) which will be
a much smaller matrix. \(Q_1'Y\) will be a submatrix of \(Q'Y\). In particular,
and \(Q_2'Y\) is the remaining submatrix:
Suppose that \(X\) is an NxK dataset of independent variables and \(Y\) is an Nx1 vector of dependent variables. Suppose further that \(X\) contains linearly dependent columns, i.e., \(X\) has rank \(M < P\). Then define
and the vector (or matrix of \(L > 1\)) of least squares coefficients of the reduced, linearly independent problem is the solution of
To solve for b use qrsol()
:
b = qrsol(C, A);
If \(N < P\), the factorization assumes the form:
where \(R_1\) is a PxP upper triangular matrix and \(R_2\) is \(P \times (N-P)\). Thus \(Q\) is a PxP matrix and \(R\) is a PxN matrix containing \(R_1\) and \(R_2\). This type of factorization is useful for the solution of underdetermined systems. For the solution of
it can be shown that
b = qrsol(Q'Y, R1)|zeros(N-P,1);
Source#
qtyr.src