On Sun, 17 May 2009 christoph.klein(a)stud.uni-karlsruhe.de wrote:
for my diploma thesis I need to do an estimation of an ols
system which has not the same number of entries as my dataset.
The data is stored within a matrix... I tried to solve the
problem with an own implementation of the ols regression:
<script>
function olsRegression(matrix y, matrix x)
matrix coff=inv(x'*x)*x'*y
return matrix coff
end function
</script>
The problem here is: if the data is not well behaved, x'*x
cannot be inverted. Did I miss anything in docs? Does anyone of
you have code doing ols with QR or SVD decomposition? The code
needs to run often, so calling out to R would slow down the
whole program to much.
Use the built-in function "mols" (see /Help/Function reference).
This function uses Cholesky decomposition by default, but switches
to QR if X'X is near-singular (since gretl 1.8.0). You can also
do
set svd on
to ask gretl to use SVD for the mols function.
Allin Cottrell