I have a need to do very very fast and efficient way of rolling linear regression. I looked through these two threads :
So, obviously, same results as roll_np
(which, I've checked the same way, are the same results as the two others. With also the same variation on indexing since all 3 methods have not the same strategy for border)
And the interesting part, timings:
Method | Time |
---|---|
pandas | 2.10 s |
numpy roll | 2.03 s |
stat | 3.58 s |
numpy view/vectorize | 0.46 s |
So, you see, it is not supposed to be for performance, and yet, I gain more that x4 times with it.
I am pretty sure that a more vectorized method (alas, lstsq doesn't allow directly it, unlike most numpy functions) would be even faster.