CointegratingRegressionDurbinWatson

Incremental, causal technical analysis documentation

Durbin–Watson diagnostic on contemporaneously refitted cointegrating residuals.

Fit y on deterministic terms and x. CRDW = Σ(Δy−βΔx−trend slope)²/RSS from the current first stage. Rolling QR estimates the slope, while expiring cross-products of adjacent differences supply the numerator. Severe cancellation triggers direct evaluation of the current edges. O(1) amortized time and O(w) memory for this bivariate model, with O(w) reconstruction. Larger values reject no cointegration. Only the constant, bivariate, w=100 case includes the Table I reference cutoffs (.511, .386, .322), based on the authors’ independent random-walk design. Other cases have empty critical_values. Compared with directly refitted NumPy residuals.

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.CointegratingRegressionDurbinWatson(window=64)
for i in range(64):
    value = rng.gauss(0, 1)
    predictor = rng.gauss(0, 1)
    result = model.update(value, predictor)
print(result.statistic)

Reference

Engle and Granger (1987), Econometrica 55, 251–276, Table I.