The Kalman Filter

Time Series Analysis
kalman
filtering
state-space
Recursive optimal estimation for linear-Gaussian state-space models
Published

April 17, 2026

Introduction

The Kalman filter recursively estimates the state of a linear-Gaussian state-space model from noisy observations. Each time step produces a filtered estimate (state given observations so far) with associated uncertainty.

Prerequisites

State-space models.

Theory

Two alternating steps:

  • Predict: \(x_{t|t-1} = G x_{t-1|t-1}\), \(P_{t|t-1} = G P_{t-1|t-1} G^\top + W\).
  • Update: \(x_{t|t} = x_{t|t-1} + K_t (y_t - F x_{t|t-1})\), where \(K_t = P_{t|t-1} F^\top (F P_{t|t-1} F^\top + V)^{-1}\).

Optimal under linear-Gaussian assumptions.

Extensions: extended Kalman (linearise around current estimate) and unscented Kalman (sigma-point) for non-linear models.

Assumptions

Linear-Gaussian state-space; known parameters.

R Implementation

library(dlm)

# Local-level model on Nile
mod <- dlmModPoly(order = 1, dV = 15100, dW = 1470)
filt <- dlmFilter(Nile, mod)

plot(Nile)
lines(dropFirst(filt$m), col = "red", lwd = 2)

# Smoother
smo <- dlmSmooth(filt)
lines(dropFirst(smo$s), col = "blue", lwd = 2)

Output & Results

Filtered and smoothed state estimates; both overlaid on the series.

Interpretation

“The Kalman filter produced one-step-ahead forecasts; smoothing used future data for a retrospective best estimate at each time.”

Practical Tips

  • For non-linear models, use the extended or unscented Kalman filter.
  • Particle filters handle arbitrary non-linear / non-Gaussian models at higher cost.
  • Uncertainty in predict / update is propagated naturally.
  • Log-likelihood of the model can be computed from innovations; used for MLE of parameters.
  • Choice of initial state / variance matters for the first few time steps.