Chapter 10
Rigorous

State-Space Models and the Kalman Filter

00 · Symbol Glossary

$\alpha_t$alpha sub t — state vector

The latent Markov state at date tt. What you care about but do not observe directly: a local level, a time-varying beta, an ARMA companion vector.

$a_{t\mid t-1},\ P_{t\mid t-1}$predicted state and its covariance

att1=E[αtY1:t1]a_{t\mid t-1}=\mathbb{E}[\alpha_t\mid Y_{1:t-1}] and Ptt1=Var(αtY1:t1)P_{t\mid t-1}=\mathrm{Var}(\alpha_t\mid Y_{1:t-1}), the Kalman prediction. After the observation yty_t arrives they become the updated ata_t, PtP_t.

$v_t,\ F_t$innovation and its variance

vt=ytZatt1v_t=y_t-Z a_{t\mid t-1} is the one-step prediction error of the observation; Ft=Var(vtY1:t1)F_t=\mathrm{Var}(v_t\mid Y_{1:t-1}). The Gaussian likelihood is built from (vt,Ft)(v_t,F_t).

$K_t$K sub t — Kalman gain

Kt=Ptt1ZFt1K_t=P_{t\mid t-1}Z^\top F_t^{-1}. How much to move the predicted state toward the new observation. Small HH (precise data) or large PP (uncertain state) means a large gain.

$A,\ Z,\ Q,\ H$the system matrices

AA moves the state forward, ZZ maps state to observation, Q=Var(ηt)Q=\mathrm{Var}(\eta_t) is state noise, H=Var(εt)H=\mathrm{Var}(\varepsilon_t) is observation noise. Many texts call the transition matrix TT; this library reserves TT for the sample length, as in every other chapter.


01 · Why State Space

ARMA, GARCH, and VARs write the observable as a finite lag of itself. Many finance objects are latent: a slowly moving mean, a time-varying regression coefficient, a factor that several yields load on. A state-space model splits the problem in two: a Markov equation for the hidden state, and an observation equation that sees a linear image of that state plus noise.

Every causal ARMA has a state-space form (companion state). The converse is broader: the observation matrix ZZ can be time-varying (a regressor xtx_t), and the state can be a random walk. The Kalman filter is the recursive MMSE estimator of αt\alpha_t given data through tt, when the system is linear and the noises are uncorrelated through time. Under Gaussian noises it is also the conditional mean, and it delivers the Gaussian likelihood as a byproduct.


02 · The Linear Gaussian System

Definition — Time-Invariant State Space
αt=Aαt1+Rηt,yt=Zαt+εt\alpha_t = A\alpha_{t-1} + R\eta_t, \qquad y_t = Z\alpha_t + \varepsilon_t

with ηtWN(0,Q)\eta_t\sim\mathrm{WN}(0,Q), εtWN(0,H)\varepsilon_t\sim\mathrm{WN}(0,H), and η\eta, ε\varepsilon uncorrelated with each other and with α0\alpha_0. Here yty_t may be a vector; the scalar case is the one to compute by hand. Time-varying ZtZ_t, AtA_t, HtH_t are allowed — the filter formulas below still hold with tt subscripts.

Which timing convention this is

Two conventions circulate and they are not interchangeable. Here the state is dated contemporaneously: αt\alpha_t is driven by ηt\eta_t, and yty_t observes that same αt\alpha_t (Harvey’s form). Durbin and Koopman instead write αt+1=Aαt+Rηt\alpha_{t+1}=A\alpha_t+R\eta_t, so their state equation looks one period ahead and their “predicted state” is indexed differently. The filters agree on the same model; the subscripts do not. When you copy a recursion out of a book, copy its timing convention with it, or the prediction step will be off by one period.

Example — Local level (random walk plus noise)
μt=μt1+ηt,yt=μt+εt\mu_t=\mu_{t-1}+\eta_t, \qquad y_t=\mu_t+\varepsilon_t

So αt=μt\alpha_t=\mu_t, A=1A=1, Z=1Z=1, R=1R=1. The series yty_t is I(1)I(1) plus measurement noise — a useful model for a slowly moving mean (or a noisy integrated price). Signal-to-noise is Q/HQ/H: large QQ makes the extracted level jumpy; Q=0Q=0 recovers a constant mean.

Example — Time-varying beta
βt=βt1+ηt,rt=xtβt+εt\beta_t=\beta_{t-1}+\eta_t, \qquad r_t=x_t\beta_t+\varepsilon_t

Now Zt=xtZ_t=x_t (the observable factor or market return). The Kalman filter tracks βt\beta_t without a rolling-window OLS. This is the workhorse “dynamic CAPM / rolling beta” story, stated as a model rather than as an ad hoc window.

An AR(1)(1) Xt=ϕXt1+εtX_t=\phi X_{t-1}+\varepsilon_t is already in state-space form with αt=Xt\alpha_t=X_t, Z=1Z=1, H=0H=0 (perfect observation of the state). An ARMA(p,q)(p,q) uses a companion state αt\alpha_t of dimension max(p,q+1)\max(p,q+1) that stacks the current value and its lags so the observation equation picks off the first component; H=0H=0 then means the observed series is a noiseless linear readout of that state while the MA part lives in the state noise matrix RR.


03 · Predict and Update

Initialize with a prior (a0,P0)(a_0,P_0) (diffuse if you are agnostic). Then for t=1,2,t=1,2,\ldots:

Step-by-step — Kalman filter (one pass)
1
Predict the state: att1=Aat1a_{t\mid t-1}=A a_{t-1}, Ptt1=APt1A+RQRP_{t\mid t-1}=A P_{t-1}A^\top + RQR^\top.
2
Predict the observation: y^tt1=Zatt1\hat y_{t\mid t-1}=Z a_{t\mid t-1}. Innovation vt=ytZatt1v_t=y_t-Z a_{t\mid t-1}, with Ft=ZPtt1Z+HF_t=ZP_{t\mid t-1}Z^\top+H.
3
Gain: Kt=Ptt1ZFt1K_t=P_{t\mid t-1}Z^\top F_t^{-1}.
4
Update: at=att1+Ktvta_t=a_{t\mid t-1}+K_t v_t, Pt=Ptt1KtFtKtP_t=P_{t\mid t-1}-K_t F_t K_t^\top.

The gain KtK_t is large when the state is uncertain relative to the observation noise. If H=0H=0 and ZZ is invertible, the update pins αt\alpha_t to the observation. If Q=0Q=0 and A=IA=I, the filter is essentially recursive least squares on a constant state.

The update is often written Pt=(IKtZ)Ptt1P_t=(I-K_tZ)P_{t\mid t-1}. That is the same line: substituting Kt=Ptt1ZFt1K_t=P_{t\mid t-1}Z^\top F_t^{-1} gives KtFtKt=KtZPtt1K_tF_tK_t^\top=K_tZP_{t\mid t-1}, so the two forms agree.

Under Gaussian noises, the log-likelihood (up to a constant, for scalar yy) is

=12t=1T(logFt+vt2Ft)\ell = -\frac{1}{2}\sum_{t=1}^{T}\left(\log F_t + \frac{v_t^2}{F_t}\right)

where TT here is the sample length. Maximum likelihood of (A,Z,Q,H)(A,Z,Q,H) is then numerical optimization wrapped around the filter. That is why software estimates a local-level or a time-varying-parameter regression by “running Kalman.”

Smoothing, not derived

The filter uses data through tt. Smoothing runs a backward pass to get atT=E[αtY1:T]a_{t\mid T}=\mathbb{E}[\alpha_t\mid Y_{1:T}] — the right object for a historical extracted trend. The formulas (RTS / Durbin–Koopman disturbance smoothing) are a sequel. Use a smoother for ex-post charts; use the filter for real-time tracking and for the likelihood.

❌ Treating the Kalman path as ‘the true beta’

A plotted ata_t is an MMSE estimate under this QQ, HH, and linear Gaussian model.

Why it breaks: if βt\beta_t jumps, or εt\varepsilon_t is heavy-tailed, or ZtZ_t is misspecified, ata_t is a compromise, not an oracle. QQ in particular is weakly identified in short samples and controls how much the path wiggles.

Consequence: report QQ (or a signal-to-noise ratio), show PttP_{t\mid t} bands, and do not confuse a smooth extracted path with a discovered law of motion.


04 · What We Skip

Information-form and square-root Kalman filters (numerical stability when PP is ill-conditioned). Nonlinear filters (EKF, unscented, particle) for models that are not linear in αt\alpha_t — including stochastic volatility with logσt2\log\sigma_t^2 as state and a nonlinear observation. Those need a stronger computational / filtering course. The linear Gaussian filter above is the one that sits under ARMA likelihoods, local-level trends, and time-varying betas.


05 · Exercises

EXERCISE 10.1

Match A,Z,R,Q,HA,Z,R,Q,H to the local-level equations.

αt=μt\alpha_t=\mu_t, A=1A=1, Z=1Z=1, R=1R=1, Q=Var(ηt)Q=\mathrm{Var}(\eta_t), H=Var(εt)H=\mathrm{Var}(\varepsilon_t). The prediction is att1=at1a_{t\mid t-1}=a_{t-1}, Ptt1=Pt1+QP_{t\mid t-1}=P_{t-1}+Q.

Write A,Z,R,Q,HA,Z,R,Q,H for the local-level model yt=μt+εty_t=\mu_t+\varepsilon_t, μt=μt1+ηt\mu_t=\mu_{t-1}+\eta_t. What is Ptt1P_{t\mid t-1} in terms of Pt1P_{t-1} and QQ?

EXERCISE 10.2

Kt=Ptt1ZFt1K_t=P_{t\mid t-1}Z^\top F_t^{-1} with Z=1Z=1 and Ft=Ptt1+HF_t=P_{t\mid t-1}+H.

Kt=Ptt1/(Ptt1+H)K_t=P_{t\mid t-1}/(P_{t\mid t-1}+H). If H0H\to 0, Kt1K_t\to 1: trust the observation completely. If Ptt10P_{t\mid t-1}\to 0, Kt0K_t\to 0: trust the predicted state; the observation is ignored.

In the scalar local-level filter, simplify KtK_t. What happens as H0H\to 0? As Ptt10P_{t\mid t-1}\to 0?

EXERCISE 10.3

The likelihood is a product of N(0,Ft)N(0,F_t) densities of the innovations vtv_t.

Yes — that is the prediction-error decomposition. Once (vt,Ft)(v_t,F_t) are computed by the filter, Gaussian MLE is a numerical maximization of =12(logFt+vt2/Ft)\ell=-\frac12\sum(\log F_t+v_t^2/F_t). No batch Kalman matrix of size TT is required.

True or false: the Kalman filter computes the Gaussian likelihood of a linear state-space model as it runs. Why does that matter for estimating QQ and HH?


06 · Chapter Summary

ObjectRole
State αt\alpha_tlatent Markov factor, αt=Aαt1+Rηt\alpha_t=A\alpha_{t-1}+R\eta_t
Observationyt=Zαt+εty_t=Z\alpha_t+\varepsilon_t
Predict / updateMMSE recursion for ata_t, PtP_t
Gain KtK_ttrust data vs trust the model
(vt,Ft)(v_t,F_t)innovations; Gaussian log-likelihood
SmoothingatTa_{t\mid T}, for historical extraction

This is the last Time Series chapter. The ten-chapter arc is: discrete time and white noise \to stationarity \to ARMA \to unit roots \to forecasting \to GARCH \to VAR \to cointegration \to spectra \to state space. What was left out (long memory, Markov-switching, full Johansen derivations, particle filters) is a sequel, not a hole in the core.