On Fri, 16 Feb 2018, Marcin Błażejowski wrote:
Hi,
I tried to replicate in gretl exercise with variable orthogonalization
explained in
https://www.stata.com/manuals13/rorthog.pdf
but after running the script (dataset in attachment):
<hansl>
set verbose off
list X = const length weight headroom trunk
X_orth = qrdecomp({X})
series olength = X_orth[,2]
series oweight = X_orth[,3]
series oheadroom = X_orth[,4]
series otrunk = X_orth[,5]
ols price X --simple
ols price const olength oweight oheadroom otrunk --simple
</hansl>
the only identical coefficient is for const.
What am I doing wrong?
Sign normalisation and scaling. Try this:
<hansl>
list X = const length weight headroom trunk
matrix R = {}
X_orth = qrdecomp({X}, &R)
norm = (diag(R)[2:]' .> 0 ? 1 : -1) .* sdc(X_orth[,2:])
X_orth[,2:] = X_orth[,2:]./norm
</hansl>
-------------------------------------------------------
Riccardo (Jack) Lucchetti
Dipartimento di Scienze Economiche e Sociali (DiSES)
Università Politecnica delle Marche
(formerly known as Università di Ancona)
r.lucchetti(a)univpm.it
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------