Am 02.02.2021 um 18:14 schrieb Artur Bala:
Hi,
Are the following commands supposed to produce the same results? indeed,
they actually don't.
# Model 2
eval inv(x'*x)*x'y
# Model 3
eval inv(x'x)*x'*y
# Model 4
eval mols(y, x)
</hansl>
OLS-built function (model 1) works fine and eliminates the extra
variables that cause multicollinearity.
Same for the OLS matrix-built function (model 4) which halts on the
ground that "Exact or near collinearity encountered"
But, models 2 & 3 give different results (i) from the OLS-built function
and (ii) one from the other. I also tried to use 'invpd()' as presented
in the Guide (Listing 17.3: OLS via matrix methods (p. 153)); same
results as Models 2 & 3.
Am I missing something?
Well, in a sense that's the classical example why the simple algebraic
formulas shouldn't be directly applied in numerical computations. Given
floating-point representation the collinearity is not "so" exact that
the inverse-computing algorithm must fail. So it returns an inverse with
absurdly large numbers (check invpd(x'x)), and the whole thing is of
course numerically unstable, because we know that it isn't even
identified in theory.
So that's exactly why mols(), svd() and so forth exist; not only in
gretl, but in any numerical algebra software.
cheers
sven