- Introduced by
- West & Harrison (dynamic models); Gelman et al. (hierarchical Bayesian framework)
- Year
- 1989–1997
- Type
- Bayesian hierarchical model for time series
- Family
- Bayesian / computational
What does it do?
A time series Bayesian hierarchical model combines the hierarchical (multilevel) Bayesian framework with a dynamic state-space structure to analyse temporal data collected on multiple units or groups.
Priors encode beliefs about both within-unit dynamics and cross-unit variation. The posterior is typically approximated by MCMC, or by particle-based methods for non-Gaussian or nonlinear state-space models, and the output includes predictive distributions for future periods rather than only point forecasts.
The intuition behind the method
Imagine tracking sales for dozens of stores over time. Each store has its own trend and seasonal pattern, but nearby stores share common features. A hierarchical model lets store-level parameters borrow strength from each other through a shared hyperprior, while the time-series layer captures how each store's pattern evolves from one period to the next. The result is richer than fitting each store independently (too noisy) or pooling all stores into one model (too coarse) — partial pooling finds the right balance automatically, guided by the data.
History
The Bayesian state-space framework, known as the dynamic linear model, is developed in West and Harrison's monograph Bayesian Forecasting and Dynamic Models, cited in the references. The framework builds on the Kalman filter for linear Gaussian state-space systems. Hierarchical extensions, which place hyperpriors on parameters shared across several series, became practical with the spread of MCMC sampling. Software such as Stan and PyMC now supports them.
When to use it
Use a time series Bayesian hierarchical model when you have repeated measurements on multiple related units (stores, patients, countries) and want to share statistical strength across units while respecting each unit's own dynamics. It is particularly valuable when some units have short histories, when you need calibrated forecast intervals rather than point forecasts, or when you need to incorporate informative priors from domain knowledge. Do not use it as a default for a single, long, stationary series where a classical ARIMA or state-space model is faster and equally accurate. Also avoid it when computation time is severely constrained, since MCMC on large panels can be slow. Before relying on the model, check its assumptions. Inspect whether the series shows drift that a random-walk level or trend can capture, or stable fluctuation around a fixed mean, which would call for a different state structure. Check that the units in the hierarchy are plausibly exchangeable, that is, that their dynamics are similar enough to share a common population distribution. Confirm with posterior predictive checks that the Gaussian state model reproduces the main features of the data. If a check fails, add the missing component, for example an explicit intervention term for a known structural break, a switching state, or a heavier-tailed observation error, rather than relying on the default specification.
Limitations and considerations
- MCMC can be computationally expensive for large panels or long series; approximate methods (variational inference, Laplace) trade accuracy for speed.
- Model specification (state components, prior choices, error distributions) requires substantive thought and is not fully automated.
- Posterior is sensitive to hyperprior choices when group-level data are sparse; prior sensitivity analysis is mandatory.
- Convergence diagnostics must be checked rigorously — a badly mixed chain can produce misleading summaries.
- The standard formulation assumes linear Gaussian state evolution; abrupt regime changes, heavy-tailed shocks or bounded outcomes require extensions (switching states, robust error distributions, non-Gaussian observation models) that add model complexity and computation.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Partial pooling balances unit-specific estimation against population-level regularisation, which reduces overfitting for units with short or sparse histories.
- Full posterior distributions give uncertainty quantification for both parameters and forecasts, not only point estimates.
- The state vector can include level, trend, seasonality and regression effects, so several dynamic components can be combined in one model.
- Missing observations are handled by the state-space filtering mechanism without a separate imputation step.
- Prior knowledge about trends or seasonal amplitudes can be encoded explicitly and then updated with the data.
Applications
- Demand forecasting across hundreds of retail locations with varying sales histories.
- Epidemiological surveillance: estimating disease incidence trends across regions sharing a common epidemic curve.
- Finance: modelling return dynamics for multiple assets with partially shared factor structures.
- Climate science: reconstructing spatially varying temperature trends from multi-station instrumental records.
- Clinical trials with repeated measures on patients nested within clinical sites.
- Marketing mix modelling where channel effects evolve over time and vary across markets.
How it works
How it works
Hyperpriors are placed on population-level parameters (for example a common mean trend or variance), and these govern the group-level parameters of each unit. Write theta_k for the parameter block of unit k (k = 1,...,K) and phi for the population-level hyperparameters. The unit-level blocks are drawn from a common population distribution, so the prior has the form p(theta_1,...,theta_K | phi) p(phi). This structure permits partial pooling: units with sparse data are pulled toward the population level, while data-rich units retain more of their own pattern.
Formula
p(\boldsymbol{\theta}) = p(\theta_1,\ldots,\theta_K \mid \phi)\,p(\phi)At each time step t the observation equation links the outcome of each unit to a linear combination of its latent state components (level, trend, seasonality, regression effects) through a design vector F_t. The observation error is typically assumed Gaussian, with a variance that is either fixed or given a prior, but it can be generalised to Student-t or other distributions for robustness.
Formula
y_t \mid \boldsymbol{\theta} \sim p(y_t \mid F_t^\top \boldsymbol{\theta}_t)The latent state vector evolves over time through a transition equation parameterised by a system matrix G_t and a process noise covariance W_t. This captures how trends drift, seasonal patterns change, and regression effects vary over time. It is the dynamic core of the dynamic linear model (DLM) or state-space formulation. Two standard special cases make the matrices concrete. In the local-level model the state is a single level, with F_t = 1 and G_t = 1, so the level follows a random walk observed with noise. In the local-linear-trend model the state is (level, slope), with F_t = (1, 0)^T and G_t = [[1, 1], [0, 1]], so the slope itself drifts over time. The standard DLM assumes linear Gaussian state evolution, a Gaussian observation error, and a W_t and observation variance that are either known or given priors.
Formula
\boldsymbol{\theta}_t = G_t \boldsymbol{\theta}_{t-1} + \boldsymbol{\omega}_t,\quad \boldsymbol{\omega}_t \sim \mathcal{N}(\mathbf{0}, W_t)Bayes' rule combines the likelihood across all times and units with the hierarchical prior, giving a joint posterior over the latent states and hyperparameters. For Gaussian dynamic linear models the Kalman filter and smoother give the filtering and smoothing distributions in closed form. Non-Gaussian or nonlinear models generally require MCMC (for example NUTS) or particle-based methods.
Formula
p(\boldsymbol{\theta}_{0:T} \mid y_{1:T}) \propto p(y_{1:T} \mid \boldsymbol{\theta}_{0:T})\,p(\boldsymbol{\theta}_{0:T})After sampling, posterior predictive distributions for future time steps are obtained by propagating samples through the state-evolution equation. Formally, the predictive distribution for a future observation y_{T+h}, given the data up to time T, integrates the observation density over the latent states between T and T+h, and over the posterior of the latent state at T and the hyperparameters. In practice this integral is approximated by averaging over MCMC draws: for each draw, the state is simulated forward h steps and then the observation is simulated. Convergence is assessed with R-hat and effective sample size, and posterior predictive checks compare replicated series with the observed data to test the model.
Common pitfalls
- Skipping convergence checks (R-hat, trace plots, effective sample size) and treating MCMC output as exact.
- Using independent priors for group-level parameters instead of a hierarchical prior, thereby losing the partial-pooling benefit.
- Omitting posterior predictive checks, which means structural misspecification (wrong trend model, missed seasonality) goes undetected.
- Conflating the model's one-step-ahead filtered distribution with the full posterior smoothed distribution when reporting estimates.
- Treating forecast credible intervals as confidence intervals and misinterpreting their probabilistic meaning.
Frequently asked questions
How is this different from a plain hierarchical Bayesian model?
A plain hierarchical model pools parameters across units but treats observations as exchangeable, so it has no notion of time order. The time series version adds a state-evolution equation that models how the latent state changes from period to period, capturing trends, seasonality and autocorrelation that a static hierarchical model ignores.
Can I use this model for non-Gaussian outcomes such as counts or binary events?
Yes. The observation equation can be replaced with a Poisson, negative-binomial or Bernoulli likelihood, while the latent state still evolves as a Gaussian dynamic model. Inference then generally requires MCMC, because the Kalman filter no longer applies exactly, but the hierarchical structure and partial pooling work in the same way.
How many units do I need for the hierarchical structure to be useful?
There is no fixed minimum. When only a handful of units are available, the hyperprior is informed by little data and the partial-pooling effect is weak. The approach gains most when many units are observed, because units with sparse data can borrow strength from the rest.
What software implements this model?
Stan (via RStan or PyStan) and PyMC both support full MCMC for custom hierarchical state-space models. bsts (Bayesian structural time series) in R provides a convenient interface for common specifications.
How do I compare two competing hierarchical time series models?
Use leave-one-out cross-validation (LOO-CV) via the loo package, or compute the widely applicable information criterion (WAIC). Both are computed from MCMC samples and account for posterior uncertainty, so they are generally preferred to point-estimate criteria such as AIC or BIC in a Bayesian setting.
Related methods
Sources
West, M. & Harrison, J. (1997). Bayesian Forecasting and Dynamic Models (2nd ed.). Springer.
ISBN: 978-0387947259Gelman, A., Carlin, J. B., Stern, H. S., Dunson, D. B., Vehtari, A. & Rubin, D. B. (2013). Bayesian Data Analysis (3rd ed.). CRC Press.
ISBN: 978-1439840955