Kalman Filter

state-spacekalman-filterfilteringsmoothinglinear-gaussiantime-varying-parameterunobserved-componentsmaximum-likelihood

Definition

The Kalman filter is a recursive algorithm that computes the minimum mean squared error (MMSE) linear estimator of the latent state vector αt\boldsymbol{\alpha}_t in a linear Gaussian state-space model, given all observations up to time tt. At each step it alternates between a prediction step (propagating the state one period forward via the transition equation) and an update step (revising the prediction using the new observation and the Kalman gain). Under Gaussianity the filtered estimates equal the conditional means, and the filter delivers the exact log-likelihood as a by-product via the innovation decomposition.

Key Ideas

How It Works

State-Space Form

yt=Ztαt+εt,εtN(0,Ht)(measurement)\mathbf{y}_t = \mathbf{Z}_t \boldsymbol{\alpha}_t + \boldsymbol{\varepsilon}_t, \qquad \boldsymbol{\varepsilon}_t \sim \mathcal{N}(\mathbf{0}, \mathbf{H}_t) \tag{measurement}

αt=Ttαt1+Rtηt,ηtN(0,Qt)(transition)\boldsymbol{\alpha}_t = \mathbf{T}_t \boldsymbol{\alpha}_{t-1} + \mathbf{R}_t \boldsymbol{\eta}_t, \qquad \boldsymbol{\eta}_t \sim \mathcal{N}(\mathbf{0}, \mathbf{Q}_t) \tag{transition}

where yt\mathbf{y}_t is p×1p \times 1 observed, αt\boldsymbol{\alpha}_t is m×1m \times 1 latent, and (εt,ηt)(\boldsymbol{\varepsilon}_t, \boldsymbol{\eta}_t) are mutually uncorrelated at all leads and lags.

Prediction Step

att1=Ttat1t1,Ptt1=TtPt1t1Tt+RtQtRt\mathbf{a}_{t|t-1} = \mathbf{T}_t \mathbf{a}_{t-1|t-1}, \qquad \mathbf{P}_{t|t-1} = \mathbf{T}_t \mathbf{P}_{t-1|t-1} \mathbf{T}_t' + \mathbf{R}_t \mathbf{Q}_t \mathbf{R}_t'

Update Step

vt=ytZtatt1,Ft=ZtPtt1Zt+Ht\mathbf{v}_t = \mathbf{y}_t - \mathbf{Z}_t \mathbf{a}_{t|t-1}, \qquad \mathbf{F}_t = \mathbf{Z}_t \mathbf{P}_{t|t-1} \mathbf{Z}_t' + \mathbf{H}_t

Kt=Ptt1ZtFt1\mathbf{K}_t = \mathbf{P}_{t|t-1} \mathbf{Z}_t' \mathbf{F}_t^{-1}

att=att1+Ktvt,Ptt=(IKtZt)Ptt1\mathbf{a}_{t|t} = \mathbf{a}_{t|t-1} + \mathbf{K}_t \mathbf{v}_t, \qquad \mathbf{P}_{t|t} = (\mathbf{I} - \mathbf{K}_t \mathbf{Z}_t) \mathbf{P}_{t|t-1}

Kalman Smoother (Rauch-Tung-Striebel)

Run the filter forward; then pass backward for t=T1,,1t = T-1, \ldots, 1:

Lt=PttTt+1Pt+1t1\mathbf{L}_t = \mathbf{P}_{t|t} \mathbf{T}_{t+1}' \mathbf{P}_{t+1|t}^{-1}

atT=att+Lt(at+1Tat+1t),PtT=Ptt+Lt(Pt+1TPt+1t)Lt\mathbf{a}_{t|T} = \mathbf{a}_{t|t} + \mathbf{L}_t (\mathbf{a}_{t+1|T} - \mathbf{a}_{t+1|t}), \qquad \mathbf{P}_{t|T} = \mathbf{P}_{t|t} + \mathbf{L}_t (\mathbf{P}_{t+1|T} - \mathbf{P}_{t+1|t}) \mathbf{L}_t'

Log-Likelihood for MLE

(θ)=Tp2log(2π)12t=1T(logFt+vtFt1vt)\ell(\theta) = -\frac{Tp}{2}\log(2\pi) - \frac{1}{2}\sum_{t=1}^T \left(\log|\mathbf{F}_t| + \mathbf{v}_t'\mathbf{F}_t^{-1}\mathbf{v}_t\right)

Maximised over model parameters θ\theta via quasi-Newton methods (e.g., Broyden-Fletcher-Goldfarb-Shanno (BFGS)).

Exact Diffuse Initialisation (Koopman 1997)

Nonstationary models (regression effects, stochastic trend/seasonal, ARIMA components) have a partly diffuse initial state: α1=a+Aη+Bδ\boldsymbol{\alpha}_1 = \mathbf{a} + \mathbf{A}\boldsymbol{\eta} + \mathbf{B}\boldsymbol{\delta} with δN(0,κI)\boldsymbol{\delta}\sim\mathcal N(\mathbf 0,\kappa\mathbf I) and κ\kappa\to\infty, so the initial variance splits as P1=P+κP\mathbf{P}_1 = \mathbf{P}_* + \kappa\mathbf{P}_\infty. The ordinary filter cannot run because P0\mathbf{P}_\infty\neq\mathbf 0. The historical fix — set κ\kappa to a large constant (107\sim 10^7) — is inexact and rounding-prone.

Koopman (1997) obtains the exact solution analytically: write each filtering quantity as an explicit function of κ\kappa (Ft=F,t+κF,t\mathbf{F}_t=\mathbf{F}_{*,t}+\kappa\mathbf{F}_{\infty,t}, Mt=M,t+κM,t\mathbf{M}_t=\mathbf{M}_{*,t}+\kappa\mathbf{M}_{\infty,t}), expand Ft1\mathbf{F}_t^{-1} in powers of 1/κ1/\kappa, and let κ\kappa\to\infty to get exact recursions for at+1\mathbf{a}_{t+1}, the finite part P,t+1\mathbf{P}_{*,t+1}, and the diffuse part P,t+1\mathbf{P}_{\infty,t+1} — from a trivial initialization (P,1,P,1)(\mathbf{P}_{*,1},\mathbf{P}_{\infty,1}). As diffuse information is consumed the rank of P,t\mathbf{P}_{\infty,t} falls (r(P,t+1)r(P,t)r(F,t)r(\mathbf{P}_{\infty,t+1})\le r(\mathbf{P}_{\infty,t})-r(\mathbf{F}_{\infty,t})) and the recursion collapses automatically back to the ordinary Kalman filter — no manual switch. An exact diffuse smoother, the diffuse likelihood and score, and clean missing-observation handling (delete the relevant rows of Zt,Gt\mathbf{Z}_t,\mathbf{G}_t) all follow. This supersedes the Ansley-Kohn (1985, 1990) transformation (exact but hard to implement) and de Jong's (1991) augmented diffuse Kalman filter (exact but costlier, with awkward smoothing corrections), and it underlies later state-space software (SsfPack) and the Durbin-Koopman (2001) textbook treatment.

Why It Matters

Open Questions

Related