Three Ways to Speed Up Rolling Linear Regression Indicators
Summary
The article explains three algorithmic approaches to reducing the computation needed for a rolling linear regression indicator: updating moving totals, simplifying the regression equation, and approximating its output. The moving-totals method reuses the previous window’s sums, subtracting the departing observation and adding the new one rather than recalculating every term. For regression, it maintains the required totals in calculation buffers. The simplification method expresses the regression value through built-in simple and linear-weighted moving averages, while approximation replaces the full calculation with a lighter estimate that can help during testing or parameter searches.
The author compares execution times and reports that moving totals was fastest in the described experiment; both moving totals and simplification are said to avoid computation that scales directly with the regression window length. Approximation trades exactness for speed, so its suitability depends on the task. The article offers implementation techniques for indicator developers, but the performance claims are tied to the author’s setup and do not establish universal speed gains on every platform or workload.
Key ideas
- Rolling sums can be updated by removing the oldest observation and adding the newest one.
- Linear regression needs several rolling totals that can be retained in calculation buffers.
- The regression output can be expressed using simple and linear-weighted moving averages.
- An approximate indicator can speed up exploratory testing when exact values are not essential.
- The reported speed ranking comes from one experiment and may depend on the implementation and environment.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.