Chapter Contents Previous Next
 Language Reference

## RDODT and RUPDT Calls

downdate and update QR and Cholesky decompositions

CALL RDODT( def, rup, bup, sup, r, z<, b, y<, ssq>>);
CALL RUPDT( rup, bup, sup, r, z<, b, y<, ssq>>);

The RDODT and RUPDT subroutines return the values:

def
is only used for downdating, and it specifies whether the downdating of matrix R by using the q rows in argument z has been successful. The result def=2 means that the downdating of R by at least one row of Z leads to a singular matrix and cannot be completed successfully (since the result of downdating is not unique). In that case, the results rup, bup, and sup contain missing values only. The result def=1 means that the residual sum of squares, ssq, could not be downdated successfully and the result sup contains missing values only. The result def=0 means that the downdating of R by Z was completed successfully.

rup
is the n ×n upper triangular matrix R that has been updated or downdated by using the q rows in Z.

bup
is the n ×p matrix B of right-hand sides that has been updated or downdated by using the q rows in argument y. If the argument b is not specified, bup is not computed.

sup
is a p vector of square roots of residual sum of squares that is updated or downdated by using the q rows of argument y. If ssq is not specified, sup is not computed.

The inputs to the RDODT and RUPDT subroutines are as follows:

r
specifies an n ×n upper triangular matrix R to be updated or downdated by the q rows in Z. Only the upper triangle of R is used; the lower triangle can contain any information.

z
specifies a q ×n matrix Z used rowwise to update or downdate the matrix R.

b
specifies an optional n ×p matrix B of right-hand sides that have to be updated or downdated simultaneously with R. If b is specified, the argument y must also be specified.

y
specifies an optional q ×p matrix Y used rowwise to update or downdate the right-hand side matrix B. If b is specified, the argument y must also be specified.

ssq
is an optional p vector that, if b is specified, specifies the square root of the error sum of squares that should be updated or downdated simultaneously with R and B.

The upper triangular matrix R of the QR decomposition of an m ×n matrix A,
A = QR, where Q' Q = QQ' = Im
is recomputed efficiently in two cases:
• update: An n vector z is added to matrix A.
• downdate: An n vector z is deleted from matrix A.
Computing the whole QR decomposition of matrix A by Householder transformations requires 4mn2 - 4n3/3 floating point operations, whereas updating or downdating the QR decomposition (by Givens rotations) of one row vector z requires only 2n2 floating point operations.

If the QR decomposition is used to solve the full rank linear least-squares problem
minx | Ax- b|2 = ssq
by solving the nonsingular upper triangular system
x = R-1 Q' b
then the RUPDT and RDODT subroutines can be used to update or downdate the p-transformed right-hand sides Q' B and the residual sum-of-squares p vector ssq provided that for each n vector z added to or deleted from A there is also a p vector y added to or deleted from the m ×p right-hand-side matrix B.

If the arguments z and y of the subroutines RUPDT and RDODT contain q > 1 row vectors for which R (and Q' B, and eventually ssq) is to be updated or downdated, the process is performed stepwise by processing the rows zk (and yk), k = 1, ... ,q, in the order in which they are stored.

The QR decomposition of an m ×n matrix A, , rank(A) = n,
A = QR, where Q' Q = QQ' = Im
corresponds to the Cholesky factorization
C = R' R, where C = A' A
of the positive definite n ×n crossproduct matrix C = A' A. In the case where and rank(A) = n, the upper triangular matrix R computed by the QR decomposition (with positive diagonal elements) is the same as the one computed by Cholesky factorization except for numerical error,
A' A = (QR)' (QR) = R' R
Adding a row vector z to matrix A corresponds to the rank-1 modification of the crossproduct matrix C
and the (m+1) ×n matrix contains all rows of A with the row z added.

Deleting a row vector z from matrix A corresponds to the rank-1 modification
C* = C- z' z, where C* = A*' A*
and the (m-1) ×n matrix A* contains all rows of A with the row z deleted. Thus, you can also use the subroutines RUPDT and RDODT to update or downdate the Cholesky factor R of a positive definite crossproduct matrix C of A.

The process of downdating an upper triangular matrix R (and eventually a residual sum-of-squares vector ssq) is not always successful. First of all, the downdated matrix R could be rank deficient. Even if the downdated matrix R is of full rank, the process of downdating can be ill conditioned and does not work well if the downdated matrix is close (by rounding errors) to a rank-deficient one. In these cases, the downdated matrix R is not unique and cannot be computed by subroutine RDODT. If R cannot be computed, def returns 2, and the results rup, bup, and sup return missing values.

The downdating of the residual sum-of-squares vector ssq can be a problem, too. In practice, the downdate formula

cannot always be computed because, due to rounding errors, the radicand can be negative. In this case, the result vector sup returns missing values, and def returns 1.

You can use various methods to compute the p columns xk of the n ×p matrix X that minimize the p linear least-squares problems with an m ×n coefficient matrix A, , rank(A) = n, and p right-hand-side vectors bk (stored columnwise in the m ×p matrix B). The first of the following methods solves the normal equations and cannot be applied to the example with the 6 ×5 Hilbert matrix since too much rounding error is introduced. Therefore, use the following simple example:

   proc iml;
a = { 1 3 ,
2 2 ,
3 1 };
b = { 1, 1, 1};
m = nrow(a);
n = ncol(a);
p = 1;

• Cholesky Decomposition of Crossproduct Matrix:
   aa = a * a; ab = a * b;
r  = root(aa);
x  = trisolv(2,r,ab);
x  = trisolv(1,r,x);

• QR Decomposition by Householder Transformations:
   call qr(qtb,r,piv,lindep,a, ,b);
x = trisolv(1,r[,piv],qtb[1:n,]);

• Stepwise Update by Givens Rotations:
   r = j(n,n,0.); qtb = j(n,p,0.); ssq = j(1,p,0.);
do i = 1 to m;
z = a[i,];
y = b[i,];
call rupdt(rup,bup,sup,r,z,qtb,y,ssq);
r   = rup;
qtb = bup;
ssq = sup;
end;
x = trisolv(1,r,qtb);

Or equivalently:
   r   = j(n,n,0.);
qtb = j(n,p,0.);
ssq = j(1,p,0.);
call rupdt(rup,bup,sup,r,a,qtb,b,ssq);
x   = trisolv(1,rup,bup);

• Singular Value Decomposition:
   call svd(u,d,v,a);
d = diag(1 / d);
x = v * d * u * b;

For the preceding 3 ×2 example matrix A, each method obtains the unique LS estimator:
   ss = ssq(a * x - b);
print ss x;


To compute the (transposed) matrix Q, you can use the following specification:

   r = shape(0,n,n);
y = i(m);
qt = shape(0,n,m);
call rupdt(rup,qtup,sup,r,a,qt,y);
`

 Chapter Contents Previous Next Top