The decgr routine may return incorrect pivots if a linear dependency is
detected in the input matrix. In a sense this is fair since this could
be considered a failure where no useful output is available.
The only thing is that the output is useful in many cases. decqr returns
a correct decomposition for the linearly independent columns. IF the
correct pivot was returned one could do a number of useful things.
1) Compute a generalized inverse of X'X.
2) Solve the underlying equation system subject to, say, setting
coefficients corresponding to the problem columns to zero.
3) Identify candidates for removal from the equation system (problem
columns of X will have zero or very small diagonal elements in the R
matrix, but we don't know which they are without the correct pivot).
This also effects the ability of OxGauss to replicate Gauss behaviour
since the corresponding functions in Gauss return correct pivots.
The following program illustrates the problem. Note that a correct pivot
is returned when the "problem" column is either first or last in X and
an incorrect pivot is returned otherwise.
/Sune
#include <oxstd.h>
main() {
decl t, z, correctpivot, x, idx;
decl mht, mr, mp, ret;
t = 100;
ranseed(242);
z = rann( t, 1 )~rann(t,1)*2~rann(t,1)*3;
z = z~(z[][0]+z[][1])/5; // create linear dependency
// try different ordering of the variables
idx = <0, 1, 2, 3>;
x = z[][idx];
t = decqr(x, &mht, &mr, &mp);
print("idx",idx);
println("Pivot should be 2, 1, 0, 3");
print("Returned pivot",mp[0][]);
print("r",mr);
println("");
idx = <0, 1, 3, 2>;
x = z[][idx];
t = decqr(x, &mht, &mr, &mp);
print("idx", idx);
println("Pivot should be 3, 1, 0, 2");
print("Returned pivot",mp[0][]);
print("r",mr);
println("");
idx = <0, 3, 1, 2>;
x = z[][idx];
t = decqr(x, &mht, &mr, &mp);
print("idx",idx);
println("Pivot should be 3, 2, 0, 1");
print("Returned pivot",mp[0][]);
print("r",mr);
println("");
idx = <3, 0, 1, 2>;
x = z[][idx];
t = decqr(x, &mht, &mr, &mp);
print("idx",idx);
println("Pivot should be 3, 2, 1, 0");
print("Returned pivot",mp[0][]);
print("r",mr);
}
--
Sune Karlsson | Fax: + 46 8 34 81 61
Stockholm School of Economics | Phone: + 46 8 736 92 39
Box 6501, 113 83 Stockholm, Sweden | http://www.hhs.se/personal/SuneK/
http://econpapers.hhs.se/ | http://swopec.hhs.se/
======================================================================
September 15 to December 19:
University of California, San Diego
Department of Economics, 0508
9500 Gilman Drive
La Jolla, CA 92093-0508
(858) 822-0585
|