Rolling Regression

A rolling regression does a lot of redundant work inside of several levels of (slow) for loops. Attaullah Shah describes his faster -asreg- command in this Stata Forum entry. I did a brief test and found that with one a million observations on 2 variables, -asreg- could do about 3,000 regressions per minute over a window size of 100.

It seem as though nearly all regressions require some special technique such as 2SLS, clustering, or hetero-skedastic standard errors, none of which are available here. An easy way to obtain corrected standard errors for a manual implementation of 2SLS is to regress the 2nd stage residuals (calculated with the real, not predicted data) on the independent variables. Those standard errors are unbiased for the coefficients of the 2nd stage regression.

I have not tested -rollreg-, but here is a description. And there is -rolling-.


last update 20 Nov 2017 by drf