Repository logo

Bayesian context trees: Modelling and exact inference for discrete time series

Published version

Change log


Mertzanis, L 
Panotopoulou, A 
Papageorgiou, I 
Skoularidou, M 


We develop a new Bayesian modelling framework for the class of higher-order, variable-memory Markov chains, and introduce an associated collection of methodological tools for exact inference with discrete time series. We show that a version of the context tree weighting algorithm can compute the prior predictive likelihood exactly (averaged over both models and parameters), and two related algorithms are introduced, which identify the a posteriori most likely models and compute their exact posterior probabilities. All three algorithms are deterministic and have linear-time complexity. A family of variable-dimension Markov chain Monte Carlo samplers is also provided, facilitating further exploration of the posterior. The performance of the proposed methods in model selection, Markov order estimation and prediction is illustrated through simulation experiments and real-world applications with data from finance, genetics, neuroscience, and animal communication. The associated algorithms are implemented in the R package BCT.



Bayes factors, Bayesian context tree, context tree weighting, discrete time series, exact Bayesian inference, Markov chain Monte Carlo, Markov order estimation, model selection, prediction

Journal Title

Journal of the Royal Statistical Society. Series B: Statistical Methodology

Conference Name

Journal ISSN


Volume Title


Oxford University Press (OUP)