I must admit that replacing

lad y const x
for
quantreg 0.5 y const x

works like a charm!

The script is slower than when using OLS but manageable for an execution of 2 million regressions!

Thanks

--
Filipe Rodrigues da Costa
Send me an email to: filipe@pobox.io
Reach me through Telegram at: https://t.me/rodriguesdacosta

Additional thought: you might try replacing

lad y const x

with

quantreg 0.5 y const x

That should probably be faster for large data.

Allin