Overview

9 Time series and state-space models: Evolving a Bayesian belief over time

This chapter shifts Bayesian learning from a one-time update to an ongoing process that unfolds over time. Instead of waiting for all data to arrive, the model makes predictions, observes new evidence, and revises its belief repeatedly. That perspective is essential for time series, where data come in sequence and the main question becomes how uncertainty and predictions change at each step rather than only at the end.

To handle this setting, the chapter introduces state space models, which separate a system into a hidden state that evolves and an observation process that reveals noisy measurements of it. Using Mauna Loa CO₂ data as a running example, it shows how a filter works through a predict–update cycle: first forecasting the next latent state from the current one, then correcting that forecast with the new observation. In the simplest Bayesian case, this becomes a Kalman filter under linear dynamics and Gaussian noise, with the Kalman gain determining how much the model trusts its prior versus the data.

The initial random-walk filter is useful but limited, because it cannot capture the long-term upward trend in CO₂ well and can become overly conservative if its prior uncertainty is too small. The chapter then improves the model by making the latent state multivariate, explicitly adding a slope variable so the filter can represent persistent change and produce more realistic forecasts. It closes by placing Kalman filtering in a broader family of methods, including extended, unscented, and ensemble Kalman filters, which adapt the same recursive Bayesian idea to nonlinear systems and large-scale real-world applications.

Yearly average CO₂ concentrations measured at Mauna Loa Observatory between 1958 and 2001. The time series shows an upward trend.
When modeling a time series, we aim to make forecasts about future data. This would require accounting for the temporal dynamic of the portion of the data we have observed.
A diagram of a state space model, which includes an unknown latent space 𝑥ᵢ that evolves over time, and the observation model, which describes the relationship between the latent state and observed data 𝑦ᵢ at each time step.
The diagram of a filter algorithm, which alternates between the prediction step and the update step to recursively generate predictions for a time series.
Illustration of the state transition model that assumes the next state 𝑥ᵢ₊₁ is similar to the current state 𝑥ᵢ with some zero-mean noise added.
The Kalman gain helps the filter decide how much we should trust the model compared to the measurement when producing the filtered posterior prediction.
Mean predictions of the model generated at the prediction step (bottom right x) and at the update step (top right diamond) at the second time step given the observed data (dots).
Mean predictions of the model generated at the prediction step (bottom right x) and at the update step (top right diamond) at the third time step given the observed data (dots).
Mean predictions of the model generated at the prediction step (dashed line) and at the update step (solid line) given the observed data (dots) at each time step.
The evolution of the Kalman gain across time steps. The gain starts near 1 but quickly decreases. This trend corresponds to the filter not adjusting to observed data.
Comparison of posterior distributions adapting to data under different priors. Low prior uncertainty (small variance) leads to low adaption to data.
Behavior of the filter with a higher state transition variance, which doesn’t underestimate its predictive uncertainty and obtains higher Kalman gains. Ultimately, it adapts to observed data better than the previous filter.
Multiyear forecasts by the random walk filter. The mean predictions stay flat as the model assumes the expected value of the latent state stays the same across time.
Mean predictions of the multivariate model generated at the prediction and update steps given the data observed at various time steps.
Multiyear forecasts by the multivariate filter. The mean predictions increase linearly as a function of time, as the model assumes the expected value of yearly change in CO₂ concentration to be constant.

Summary

  • A state space model separates system dynamics from the observation process.
  • The hidden state evolves according to a transition model; data are noisy observations of that state.
  • The Kalman filter performs recursive Bayesian inference in linear Gaussian state space models.
  • Filtering computes the posterior distribution of the current state given all observations so far.
  • Each Kalman step consists of a prediction step that propagates the state forward and an update step that incorporates new data.
  • In the linear Gaussian case, the posterior remains Gaussian; tracking the mean and covariance is sufficient.
  • The Kalman gain determines how strongly new observations influence the state estimate.
  • In one dimension, the Kalman gain is a scalar; in multivariate models, it becomes a vector that quantifies information across state components.
  • A random walk model assumes incremental evolution with no explicit trend component.
  • Forecasting propagates the state forward without incorporating new observations.
  • In a random walk, multi-step forecasts have a flat predictive mean and increasing uncertainty.
  • A linear trend model augments the state with a slope component.
  • The Kalman filter provides a computationally efficient framework for sequential probabilistic reasoning in time-evolving systems.
  • The Extended Kalman Filter handles nonlinear dynamics through local linearization.
  • The Unscented Kalman Filter propagates uncertainty through nonlinear systems using deterministic sigma points.
  • The Ensemble Kalman Filter approximates the posterior with a collection of state vector samples and is widely used in large-scale systems.

FAQ

What is the main difference between a static Bayesian model and a time series model?In a static Bayesian model, we usually update our belief once after seeing all the data. In a time series model, learning is iterative: we continuously predict, observe new data, update our belief, and repeat over time.
What is a state space model?A state space model separates a system into two parts: a latent state that evolves over time, and an observation model that explains how the hidden state produces the observed data.
Why can’t the latent state in a state space model be directly observed?The latent state represents the underlying true system, such as the real CO₂ concentration, while the observed data may be noisy or incomplete. We infer the state indirectly through its relationship to the measurements.
What is a filter in the context of time series?A filter is an algorithm that estimates the latent state at each time step using all information available up to that point. It works recursively over time.
What are the two steps in the predict–update cycle?The prediction step estimates the next latent state before seeing the new observation. The update step corrects that prediction using the new data, producing the filtered posterior belief.
What is the random walk model in this chapter?The random walk model assumes the next state is equal to the current state plus zero-mean Gaussian noise. It is simple, but it does not explicitly model long-term trend.
What makes a Kalman filter a Bayesian filter?A Kalman filter performs recursive Bayesian updating under linear dynamics and Gaussian noise assumptions. It maintains distributions over hidden states and updates them with Bayes’ theorem.
What is the Kalman gain?The Kalman gain determines how much the filter trusts the new observation versus the model prediction. A high gain means the measurement has more influence, while a low gain means the model prediction dominates.
Why did the random walk filter underestimate the CO₂ trend?Its state transition variance was too small, making the prior too conservative. As a result, the filter adapted too slowly to the observed upward trend in CO₂ concentrations.
How does the multivariate Kalman filter improve forecasting of CO₂?It adds a second latent variable to model the yearly rate of change, or slope, in addition to the concentration level. This allows the model to capture persistent upward trends and produce more realistic long-term forecasts.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Grokking Bayes ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Grokking Bayes ebook for free