;SPMlt;!DOCTYPE HTML PUBLIC ;SPMquot;-//W3C//DTD HTML 3.2 Final//en;SPMquot;;SPMgt;
;SPMlt;!--Converted with LaTeX2HTML 2022 (Released January 1, 2022) --;SPMgt; ;SPMlt;HTML lang=;SPMquot;en;SPMquot;;SPMgt; ;SPMlt;HEAD;SPMgt; ;SPMlt;TITLE;SPMgt;Contents of Sweep() and Inv();SPMlt;/TITLE;SPMgt;
;SPMlt;META HTTP-EQUIV=;SPMquot;Content-Type;SPMquot; CONTENT=;SPMquot;text/html; charset=utf-8;SPMquot;;SPMgt; ;SPMlt;META NAME=;SPMquot;viewport;SPMquot; CONTENT=;SPMquot;width=device-width, initial-scale=1.0;SPMquot;;SPMgt; ;SPMlt;META NAME=;SPMquot;Generator;SPMquot; CONTENT=;SPMquot;LaTeX2HTML v2022;SPMquot;;SPMgt;
;SPMlt;LINK REL=;SPMquot;STYLESHEET;SPMquot; HREF=;SPMquot;docu.css;SPMquot;;SPMgt;
;SPMlt;LINK REL=;SPMquot;next;SPMquot; HREF=;SPMquot;node46_mn.html;SPMquot;;SPMgt; ;SPMlt;LINK REL=;SPMquot;previous;SPMquot; HREF=;SPMquot;node44_mn.html;SPMquot;;SPMgt; ;SPMlt;LINK REL=;SPMquot;up;SPMquot; HREF=;SPMquot;node41_mn.html;SPMquot;;SPMgt; ;SPMlt;LINK REL=;SPMquot;next;SPMquot; HREF=;SPMquot;node46_mn.html;SPMquot;;SPMgt; ;SPMlt;/HEAD;SPMgt;
;SPMlt;BODY bgcolor=;SPMquot;#ffffff;SPMquot; text=;SPMquot;#000000;SPMquot; link=;SPMquot;#9944EE;SPMquot; vlink=;SPMquot;#0000ff;SPMquot; alink=;SPMquot;#00ff00;SPMquot;;SPMgt;
;SPMlt;H2;SPMgt;;SPMlt;A ID=;SPMquot;SECTION00824000000000000000;SPMquot;;SPMgt;
Sweep() and Inv();SPMlt;/A;SPMgt;
;SPMlt;/H2;SPMgt;
Sweep();SPMlt;A ID=;SPMquot;262;SPMquot;;SPMgt;;SPMlt;/A;SPMgt; may be used for creating a
generalized inverse of a square matrix using Gaussian
elimination. A generalized inverse of the matrix ;SPMlt;I;SPMgt;A;SPMlt;/I;SPMgt;, say ;SPMlt;I;SPMgt;A;SPMlt;/I;SPMgt;;SPMlt;SUP;SPMgt;+;SPMlt;/SUP;SPMgt;
satisfies the properties, ;SPMlt;!-- MATH
;SPMlt;P;SPMgt;
The arguments of Sweep() are the rows to be eliminated,
from k1 to k2, and the matrix to operate on. If all rows
are eliminated, and the matrix has full rank, then the
matrix is inverted. The function,
Inv();SPMlt;A ID=;SPMquot;263;SPMquot;;SPMgt;;SPMlt;/A;SPMgt;, performs matrix inversion by
eliminating all rows and columns. If any pivot is less than
1.0E-8, then the row and column being eliminated is set to
zero. This procedure creates ;SPMlt;I;SPMgt;A;SPMlt;/I;SPMgt;;SPMlt;SUP;SPMgt;+;SPMlt;/SUP;SPMgt;.
;SPMlt;P;SPMgt;
Sweep() also simplifies the calculation of regression
coefficients and the residual mean square. Consider the
regression of ;SPMlt;I;SPMgt;X;SPMlt;/I;SPMgt;;SPMlt;SUB;SPMgt;Nxp;SPMlt;/SUB;SPMgt; on ;SPMlt;I;SPMgt;Y;SPMlt;/I;SPMgt;;SPMlt;SUB;SPMgt;Nx1;SPMlt;/SUB;SPMgt;. The steps for
calculating the regression coefficients are as follows:
;SPMlt;OL;SPMgt;
;SPMlt;LI;SPMgt;Concatenate ;SPMlt;I;SPMgt;X;SPMlt;/I;SPMgt; and ;SPMlt;I;SPMgt;Y;SPMlt;/I;SPMgt; using the statement
VMatrix XY = Ch(X,Y); This produces an Nx(p+1) matrix.
;SPMlt;/LI;SPMgt;
;SPMlt;LI;SPMgt;Calculate the matrix of crossproducts using
VMatrix xypxy = Tran(XY)*XY;
;SPMlt;/LI;SPMgt;
;SPMlt;LI;SPMgt;Calculate the coefficients by sweeping out the first p
rows of xypxy, VMatrix ixypxy = Sweep(1,p,xypxy);
;SPMlt;/LI;SPMgt;
;SPMlt;LI;SPMgt;The regression coefficients are in the right most
column: VMatrix betahat = Submat(ixypxy,p,p+1,1,p+1);
;SPMlt;/LI;SPMgt;
;SPMlt;LI;SPMgt;The mean square error is calculated from the bottom
right corner: double mse = ixypxy.m(p+1,p+1) /
((double)(X.r-X.c));
;SPMlt;/LI;SPMgt;
;SPMlt;/OL;SPMgt;
This results from sweeping out the columns of ;SPMlt;I;SPMgt;X'X;SPMlt;/I;SPMgt;. The
original matrix is partitioned as
;SPMlt;P;SPMgt;;SPMlt;!-- MATH
;SPMlt;P;SPMgt;
;SPMlt;HR;SPMgt;
;SPMlt;/BODY;SPMgt;
;SPMlt;/HTML;SPMgt;
;SPMquot;;SPMgt;;SPMlt;IMG
STYLE=;SPMquot;height: 4.48ex; vertical-align: 172.34ex; ;SPMquot; SRC=;SPMquot;img7.png;SPMquot;
ALT=;SPMquot;X'X
amp;X'Y
Y'X
amp;Y'Y
;SPMquot;;SPMgt;;SPMlt;IMG
STYLE=;SPMquot;height: 5.32ex; vertical-align: 171.71ex; ;SPMquot; SRC=;SPMquot;img10.png;SPMquot;
ALT=;SPMquot;(X'X)-1
amp;(X'X)-1X'Y
- Y'X(X'X)-1
amp;Y'(I - X(X'X)-1X')Y