RollingOLS

Incremental, causal technical analysis documentation

Windowed least squares with arbitrary fixed predictor dimension and classical inference.

Supply y and a predictor sequence of length p. Fit y = Xβ + e by minimizing RSS over the last w rows. Coefficients, standard errors and t ratios include any deterministic terms. See the common conventions for R², covariance and rank. With k total columns, ingest costs O(k²) amortized and O(wk²) at rotation. Reading the estimate costs O(k³) including rank determination and inference. A cancellation fallback costs O(wk²+k³). Storage is O(wk) for raw rows and block-boundary suffix factors. NumPy least-squares and pseudoinverse covariance comparisons include window expiration boundaries, scale shifts and collinearity.

The econometric conventions specify input validation, warm-up, reset, result fields, numerical rank and critical-value order.

Python example

import random
import rtta

rng = random.Random(42)
model = rtta.RollingOLS(window=64, predictors=2)
for i in range(64):
    value = rng.gauss(0, 1)
    result = model.update(value, [value**2, i % 3])
print(result.coefficients)

Reference

Golub and Van Loan (2013), Matrix Computations, chapters 5–6.