?=================================================================== ? BLUS residuals for a least squares regression. = ? = ? User must define the data matrix with the following line: = ? = ? NAMELIST ; X = ... $ = ? = ? User's dependent variable is Y. Change the following line = ? = ? CREATE ; Y = the dependent variable $ = ?=================================================================== ? ? Number of columns in data matrix, K, is needed later. ? CALC ; K = Col(X) $ ? ? Use the full data set to compute the least squares regression. Keep the OLS residuals. ? ? SAMPLE ; ALL $ REGRESS ; LHS = y ; RHS = X ; RES = E $ ? ? Define the first K observations to constitute the index set. ? SAMPLE ; 1 - K $ ? ? Copy KxK X0 as matrix, then X0XX = X0(X'Xinv)X0' ? MATRIX ; X0 = COPY(X) ; X0XX = X0 | XPXI(X) | X0' ? ? Q contains characteristic vectors of X0XX, ? D = diagonal matrix of characteristic roots. ? Square roots needed below. ? ; Q=CVEC(X0XX) ; D=ROOT(X0XX) ; D=DIAG(D) ? ? Set up K x K identity matrix, add to root D and invert. ? Multiply by square root of D. ? Diagonal matrix D has dh/(1+dh) on diagonal ? ; IK=IDEN(K) & SQRT(D) ; D = SQRT(D) | SINV(IK) ? ? sum(l/(1+l) qq') is obtained as a matrix quadratic form in ? the expression below. ? Obtain e0 first. Invert X0 then multiply by QDQ' times e0. ; E0 = COPY(E) ; X0IE = GINV(X0) | Q | D | Q' | E0 $ ? ? Compute for all observations. ? Blus residuals for the index set will be superfluous. SAMPLE ; ALL$ ? ? BLUS residuals = OLS residuals - a linear function of X. ? CREATE ; EBLUS = E - DOT(X,X0IE) $