This is a request I've had quite a few times in private conversations, and
something I've had to do more than once in my own projects, so I thought
it'd be good to "share the wisdom".
<hansl>
function list autodrop(list X, scalar criterion[1.0e-12])
list drop = null
matrix R
qrdecomp({X}, &R)
scalar ndrop = 0
loop i=1..nelem(X) --quiet
if criterion > abs(R[i,i])
drop += X[i]
ndrop++
endif
endloop
if ndrop > 0
printf "%d collinear variables dropped (%s)\n", \
ndrop, varname(drop)
return X - drop
else
return X
endif
end function
</hansl>
I'm just about to add the above trick to the "Cheat Sheet" chapter of the
User's guide.
-------------------------------------------------------
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
-------------------------------------------------------