Summary
KalmanInnovationResidualFOCuS chains a Kalman innovation z-score residual into
FOCuS changepoint detection. Each price update produces a normalized innovation; FOCuS
monitors that residual for mean shifts and returns signal, FOCuS statistic (score), and
the residual itself.
Update API
import rtta
ind = rtta.KalmanInnovationResidualFOCuS(
focus_threshold=10.0,
focus_sigma=1.0,
initial_price=float("nan"),
dt=1.0,
measurement_variance=0.25,
fillna=True,
)
result = ind.update(close)
# result.signal, result.score, result.residual
If the innovation is non-finite, FOCuS is not advanced and signal/score stay 0 with
the non-finite residual echoed.
Theory Of Operation
Price levels are nonstationary; innovating a constant-velocity Kalman filter yields approximately white residuals under the model. Scaling by the predicted innovation standard deviation produces a z-score residual suitable for zero-mean FOCuS (\(\mu_0 = 0\)). Changepoints then flag structural breaks: volatility jumps that mis-scale the innovation, velocity regime changes, or measurement anomalies that FOCuS sees as residual mean shifts.
Internal Kalman defaults match KalmanInnovationZScore process/measurement settings
used by the convenience constructor (position/velocity process variances \(10^{-4}\) /
\(10^{-3}\), unit initial variances, etc.).
Recurrence
1. Innovation z-score (constant-velocity Kalman, measurement \(z_t = c_t\)):
2. FOCuS on \(\rho_t\) with threshold \(h=\)focus_threshold, \(\mu_0=0\),
\(\sigma=\)focus_sigma (see focus.md):
Outputs: \(\mathrm{score}_t = \Lambda_t\), \(\mathrm{residual}_t = \rho_t\).
Implementation Notes
The recurrence is implemented in src/rtta/indicator.cpp in
class KalmanInnovationResidualFOCuS (KalmanInnovationZScore innov_ + FOCuS focus_).
Result type is InnovationChangepointResult.
