Skip to content
  • Overview
  • Curriculum
    • FLUMental maths and numerical fluency
    • COMBCounting and combinatorics
    • PROBProbability
    • STATStatistics and inference
    • REGRegression and econometrics
    • TSTime series
      • 1Foundations

        • Foundations: stationarity, autocorrelation and the Wold decomposition
      • 2The ARMA family

        • The ARMA family: identification, estimation and forecasting
      • 3Unit roots and cointegration

        • Unit roots, spurious regression and the basis of pairs trading
      • 4Volatility modelling

        • Volatility models: ARCH, GARCH and realised measures
      • 5State space and filtering

        • State space and the Kalman filter
      • 6Financial stylised facts

        • Stylised facts: what financial returns actually look like
      • 7Forecast evaluation

        • Forecast evaluation: walk-forward design and backtest overfitting
    • LALinear algebra
    • SCStochastic calculus
    • MLMachine learning
    • SIGAlpha and signal research
    • CASEResearch case studies

Practise

  • Question bank
  • Mental arithmetic
  • Market simulator
  • Arbitrage trees
  • Horse racing
  • Bid book
  • Screening tests
  • Mock papers

Reference

  • Formula reference
  • Search

Your record

  • Review queue
  • Progress
  • Leaderboard
  • Profile
  • Invite friends
AccountSend feedback
  1. Curriculum
  2. /Quantitative research
  3. /Time series
  4. /State space and filtering

State space and the Kalman filter

TS · Chapter 5·12 min read·Asked at Two Sigma, Citadel, DE Shaw, Jump

Assumes The ARMA family: identification, estimation and forecasting.

After this lesson you should be able to

  • Write a problem in state-space form.
  • Describe the predict–update cycle and what the Kalman gain does.
  • Say where a filter beats a rolling window.

A state-space model separates what you want to know from what you can see. The Kalman filter is the optimal way to track the first given a stream of the second, and in finance the thing you want to know is almost always a slowly changing parameter — a beta, a fair value, a hedge ratio — observed only through noise.

Equation 5.1

State-space form

The state evolves on its own and you observe a noisy function of it. Nearly every time-series model can be written this way, which is what makes the filter so general.

xt=Fxt−1+wt⏟state,yt=Hxt+vt⏟observation\underbrace{x_t = Fx_{t-1} + w_t}_{\text{state}}, \qquad \underbrace{y_t = Hx_t + v_t}_{\text{observation}}statext​=Fxt−1​+wt​​​,observationyt​=Hxt​+vt​​​
wt∼N(0,Q)w_t \sim N(0, Q)wt​∼N(0,Q)
Process noise — how fast the state is allowed to move.
vt∼N(0,R)v_t \sim N(0, R)vt​∼N(0,R)
Observation noise — how unreliable each measurement is.

Derivation 5.2

Predict and update

Each step has two halves: extrapolate, then correct by what you saw.

  1. x^t∣t−1=Fx^t−1,Pt∣t−1=FPt−1F⊤+Q\hat{x}_{t|t-1} = F\hat{x}_{t-1}, \qquad P_{t|t-1} = FP_{t-1}F^\top + Qx^t∣t−1​=Fx^t−1​,Pt∣t−1​=FPt−1​F⊤+Q

    Predict: the estimate moves forward and the uncertainty grows.

  2. Kt=Pt∣t−1H⊤(HPt∣t−1H⊤+R)−1K_t = P_{t|t-1}H^\top\left(HP_{t|t-1}H^\top + R\right)^{-1}Kt​=Pt∣t−1​H⊤(HPt∣t−1​H⊤+R)−1

    The Kalman gain: how much to trust this observation.

  3. x^t=x^t∣t−1+Kt(yt−Hx^t∣t−1)\hat{x}_t = \hat{x}_{t|t-1} + K_t\left(y_t - H\hat{x}_{t|t-1}\right)x^t​=x^t∣t−1​+Kt​(yt​−Hx^t∣t−1​)

    Update: move toward the surprise, in proportion to the gain.

a recursive estimate using all data so far, with no need to store it\text{a recursive estimate using all data so far, with no need to store it}a recursive estimate using all data so far, with no need to store it

What the gain is really doing. The Kalman gain is a ratio of uncertainties: how unsure you are about the state, against how unsure you are about the measurement. When your state estimate is stale and the observation is clean, the gain is near one and you essentially take the new reading. When you are already confident and the reading is noisy, the gain is near zero and you barely move. It is the precision-weighted average from Bayesian updating, applied recursively — and the filter is exactly the Bayesian posterior when everything is linear and Gaussian.

Example 5.3

You track a hedge ratio with state variance P=0.04P = 0.04P=0.04 and observation variance R=0.16R = 0.16R=0.16, with H=1H = 1H=1. Your estimate is 1.201.201.20 and the new observation implies 1.501.501.50. What is your updated estimate?

Show the worked solutionHide the worked solution

Worked solution

  1. Formula
    K=PP+R,x^←x^+K(y−x^)K = \frac{P}{P + R}, \qquad \hat{x} \leftarrow \hat{x} + K(y - \hat{x})K=P+RP​,x^←x^+K(y−x^)
  2. Substitute
    K=0.040.04+0.16=0.2K = \frac{0.04}{0.04 + 0.16} = 0.2K=0.04+0.160.04​=0.2
  3. Solve
    x^=1.20+0.2(1.50−1.20)\hat{x} = 1.20 + 0.2(1.50 - 1.20)x^=1.20+0.2(1.50−1.20)
  4. =1.20+0.06= 1.20 + 0.06=1.20+0.06
  5. Answer
    1.261.261.26

Sanity check. The observation is four times noisier than the state estimate, so you move only a fifth of the way toward it. Raise the process noise QQQ and the filter tracks faster; raise RRR and it smooths harder. Those two knobs are the entire tuning problem.

The rest of this lesson is in Premium

You have read the opening. 11 more sections follow, including 2 worked examples and 3 quick checks.

Start the free 7-day trialSign in

Nothing is charged for 7 days, and you can cancel before then. Or read The law of large numbers and the central limit theorem in full, free.

← Volatility models: ARCH, GARCH and realised measuresStylised facts: what financial returns actually look like →
On this page
  • State-space form
  • Predict and update
  • Worked example

QuantMax · 141 lessons · 1342 questions · c5c0caa

  • Premium
  • Arbitrage trees
  • Horse racing
  • Invite friends
  • Account
  • About QuantMax
  • Terms
  • Privacy

Firm names identify publicly reported question patterns and nothing more. QuantMax is not affiliated with, endorsed by, or recruiting for any firm named in the curriculum. Everything you do in lessons and the question bank is kept to your account.