Kalman Filter — Financial State-Space Model

Statistics
Introduced by
Harvey (structural time series treatment); Kim & Nelson (state-space with regime switching)
Year
1989
Type
Linear state-space model

What does it do?

The Kalman filter is a recursive algorithm for estimating models with time-varying parameters, hidden factors, and noisy observations within a linear state-space framework.

Harvey (1989) set out its structural time series treatment, and Kim and Nelson (1999) extended the state-space approach to models with regime switching. In finance it is used for problems such as pairs-trading hedge ratios, time-varying beta, and yield-curve dynamics.

The intuition behind the method

Imagine tracking a quantity you cannot observe directly, such as a stock's current hedge ratio or its rolling beta, using only noisy market prices. The filter keeps a running estimate of that hidden state and predicts where it should move next. It then adjusts the estimate toward each new observation, by an amount that depends on how much it trusts that observation relative to its own forecast. Over time this weighting of prediction against measurement lets the estimate follow a relationship that drifts.

History

The recursive filter is due to Kalman's original work. It entered econometrics through structural time series modelling: Harvey's Forecasting, Structural Time Series Models and the Kalman Filter (1989) set out this state-space treatment for economic and financial series, and Kim and Nelson's State-Space Models with Regime Switching (1999) extended the state-space approach to models whose dynamics change across regimes.

When to use it

Use the Kalman filter when the relationship you are studying changes over time rather than staying fixed, such as a drifting beta, a latent factor, or a slowly moving spread, and when you can write the system in linear state and observation equations. The basic model assumes zero-mean, normally distributed process and measurement noise and requires a specified initial state and covariance. Short samples leave the parameters poorly identified, so the length of history you need depends on the number of parameters and the signal-to-noise ratio; check identification and diagnostics for your application before relying on the estimates. Non-stationary observed series do not have to be differenced by default: non-stationary states can be modelled directly, for example with a diffuse initial state, so check stationarity and the initialisation choice before fitting. If the dynamics are clearly non-linear, use the EKF or UKF instead of the basic filter. The linear Gaussian model described here does not cover the regime-switching models in Kim and Nelson (1999), which need a different estimation approach.

Limitations and considerations

  • With short samples the parameters cannot be estimated reliably, because the likelihood used to fit them carries little information. An adequate-looking sample length does not guarantee stable estimates, so check identification and parameter stability.
  • The basic filter assumes linear dynamics with Gaussian noise. Non-linear systems need the EKF or UKF, regime-switching dynamics fall outside the linear model, and a misspecified state equation carries its error through every recursion.
  • The filtered path depends on the assumed noise covariances Q and R and on the initial state, so conclusions about drift can reflect these assumptions as much as the data.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Estimates hidden states and time-varying parameters from noisy observations, so it can follow drift that a static regression would average away.
  • Runs recursively, updating the estimate one observation at a time without refitting the whole history.
  • Places several finance problems, including pairs-trading hedge ratios, rolling betas, and yield-curve factors, in one state-space framework whose parameters can be estimated by maximum likelihood.

Applications

  • Pairs trading, where a time-varying hedge ratio between two related assets is estimated. The filtered ratio is a model-based estimate whose out-of-sample accuracy must be tested before use.
  • Estimating a stock's beta as it changes over time rather than as a single fixed value. The estimates depend on the assumed noise covariances and should be tested out of sample before they inform decisions.
  • Yield-curve modelling, where latent level, slope, and curvature factors are extracted from observed rates.

How it works

How it works

1

The model is written as two linear equations. The state equation describes how an unobserved state vector x (for example a latent factor or a time-varying coefficient) evolves from one period to the next through a transition matrix F, plus process noise w. The observation equation links the observed data y to that hidden state through a matrix H, plus measurement noise v. Both noise terms are zero-mean and normally distributed, with covariances Q and R, and an initial state and covariance must be specified.

Formula
x_t = F x_{t-1} + w_t,\quad y_t = H x_t + v_t,\quad w_t\sim N(0,Q),\ v_t\sim N(0,R)
2

Estimation is recursive and runs as a predict-then-update cycle. Each period the filter predicts the next state and its uncertainty, then computes the Kalman gain K_t, which sets how strongly the new observation is weighted against the prediction. The state estimate is then updated by the gain multiplied by the prediction error (the innovation). The filter also carries the state covariance forward: the prediction step propagates it through F and adds Q, and the update step reduces it according to the gain. The same recursion produces the likelihood, so unknown system parameters can be estimated by maximum likelihood, often via the EM algorithm. For non-linear systems the extended (EKF) or unscented (UKF) variants are used instead.

Formula
\hat{x}_{t|t} = \hat{x}_{t|t-1} + K_t\,(y_t - H\hat{x}_{t|t-1}),\quad K_t = P_{t|t-1}H^{\top}(HP_{t|t-1}H^{\top}+R)^{-1}

Common pitfalls

  • Applying the filter to non-stationary observed series without deciding how the non-stationary component is initialised (for example by differencing or with a diffuse initial state), which can make the recursive estimates drift and mislead.
  • Fitting on a short history and treating the resulting parameter estimates as precise when they are not well identified.
  • Setting the initial state mean and covariance carelessly, which can bias the early part of the filtered path.
  • Forcing a linear state-space form onto clearly non-linear dynamics instead of moving to the EKF or UKF.
  • Reading the filtered path as a precise, out-of-sample-accurate estimate, when it depends on the assumed Q, R and initial state.

Frequently asked questions

What is the difference between filtering and smoothing?

Filtering produces the best estimate of the state at each time using only data up to that point, which is what you need for real-time decisions. Smoothing revisits the whole sample afterwards and re-estimates each past state using all observations, giving a cleaner historical path.

How are the unknown parameters estimated?

The filter computes the likelihood as a by-product of its recursion, so the system matrices and noise covariances can be estimated by maximum likelihood, often through the EM algorithm.

What if my dynamics are non-linear?

The basic Kalman filter assumes linear state and observation equations. For non-linear systems, use the extended Kalman filter (EKF), which linearises locally, or the unscented Kalman filter (UKF), which propagates sample points through the non-linearity.

How much data do I need?

The data requirement depends on the number of parameters and the signal-to-noise ratio. Short samples can leave parameters poorly identified, so check identification and diagnostics on your own data before relying on the estimates. Non-stationary states can be modelled directly with a diffuse initial state, or the series differenced where that is appropriate.

Related methods

Sources

  1. Harvey, A. C. (1989). Forecasting, Structural Time Series Models and the Kalman Filter. Cambridge University Press.

    ISBN: 978-0521405737
  2. Kim, C. J. & Nelson, C. R. (1999). State-Space Models with Regime Switching. MIT Press.

    ISBN: 978-0262112383
  3. Matlab Econometrics Toolbox documentation, Chapter 8 State-Space Models, p. 8-35 ff. (entries on time-varying diffuse state-space models)