Basic Prerequisites: 02 · State-Space Models.
1. Intuition & Practical Objective
The Kalman filter is the predictor–corrector loop for a Gaussian state-space model. Each cycle does two things and only two things:
- Predict - push the current belief about the state forward through the transition dynamics, inflating its uncertainty (the state may have moved, and we weren’t looking).
- Correct - when a new observation arrives, form the innovation (how surprising the observation is given what we predicted), and move the belief toward the data by a fraction - the Kalman gain - that is exactly the signal-to-noise ratio at that moment.
Two properties make it the workhorse of quantitative finance:
- It is recursive and online. It never re-runs the whole history; it stores only the current state estimate and its covariance. This makes it per step regardless of how long the series is, and directly deployable in a live system.
- It is optimal. Under linearity and Gaussianity it is the minimum mean-squared-error estimator - no other estimator (linear or nonlinear) can do better. When the assumptions fail, it is still the best linear estimator (the orthogonal-projection view).
The practical objective is to give the practitioner the recursion in a form they can drop into code, with the conventions pinned down and the numerics made stable.
2. Mathematical Ground Truth & Derivations
2.1 The recursion, step by step
Given (the a-priori belief at time ), the filter processes and produces :
(Tsay Eq. 11.64, verified in the corpus.) The gain is a matrix version of the scalar weight : is the predicted observation variance (signal), adds the measurement variance (signal + noise), and maps it back to state space. When the observation is uninformative ( large), and the state just follows its prediction.
2.2 Where the gain comes from (three equivalent routes)
- Bayes / Gaussian conditioning. The joint of is Gaussian; conditioning on gives a posterior mean and covariance with . Algebra, not magic.
- Orthogonal projection (least squares). Among all linear functions of the data, the minimum-MSE state estimate is the orthogonal projection onto the observation space; solving the normal equations reproduces exactly the same . This is why the filter remains the best linear estimator even when the model is non-Gaussian.
- Weighted average of two beliefs. The predict step and the observation are two Gaussian “estimates” of the same quantity; the posterior is their variance-weighted average. is the weight on the data.
2.3 The scalar local-level case (Tsay 11.14), for cross-checking
With , , , :
This is the form to verify a matrix implementation against - it is small enough to compute by hand.
2.4 Steady state and the Riccati recursion
For a time-invariant model, the covariance recursion converges: solving the algebraic Riccati equation, after which is a constant. In steady state the filter is a fixed-coefficient linear filter, and this is the origin of the famous result that the optimal filter satisfies a Riccati (not a Wiener–Hopf) equation. Practically: you can pre-compute and run a gloriously cheap constant-gain filter - at the cost of losing adaptivity.
2.5 Maximum likelihood for free
The prediction-error decomposition (Tsay Eq. 11.25) gives the exact log-likelihood of the observations as a by-product of the recursion:
So parameters are estimated by simply maximizing this - no external likelihood machinery, and the innovations double as a model-diagnostic series (page 05).
3. Computational Implementation - the filter as a function, verified two ways
The general matrix filter is implemented exactly as §2.1. It is then run on a local-level model and its output is checked coefficient-by-coefficient against the scalar recursion - the strongest possible test that the matrix code is correct. Finally the Riccati fixed point is computed and compared to the filter’s converged gain.
The matrix implementation matches the hand-checkable scalar recursion to (the residual is the diffuse initial ; the two recursions are algebraically identical), and its converged gain equals the algebraic-Riccati fixed point computed independently - two implementations, one number.
4. Failure Modes & First-Principles Breakdowns
- Covariance blow-up / loss of symmetry. The update is only mathematically symmetric; floating-point round-off can drift it into asymmetry and even negative variance, after which the filter oscillates or diverges. Fix: use the Joseph form , which is symmetric and positive-semi-definite by construction, or use a square-root (Cholesky) implementation.
- Numerically singular . is computed every step; if a regressor is nearly collinear with another, becomes ill-conditioned and explodes. In practice solve the linear system rather than inverting, and consider a small jitter on .
- Diffuse initialization. A genuinely unknown initial state needs (S-Plus uses an
mSigma = −1sentinel). Using a large finite instead leaves a transient bias; using a large inverse is numerically disastrous. Tsay §11.1.6 treats this explicitly. - Mixing the two recursion forms. The canonical (11.64) form uses and puts the factor in ; the contemporaneous form updates as . Both are correct internally, but splicing a line from one into the other silently off-by-ones the covariance (flagged in the corpus verification of Tsay Ch 11).
5. References
- Tsay, Analysis of Financial Time Series (3rd ed.)
- Durbin & Koopman, Time Series Analysis by State Space Methods
- Welch & Bishop, An Introduction to the Kalman Filter (TR 95-041)
- Särkkä, Bayesian Filtering and Smoothing
- Hamilton, Time Series Analysis
6. Connected Graph Bridges
- Back: 02 · State-Space Models
- Continue: 04 · Time-Varying Beta · Index Hub
- Base: Linear Algebra (matrix inverse, SPD) · Probability (Gaussian conditioning)
- Robustness: 05 · Failure Modes · 06 · Smoothing & Particle Filters