Bayesian Context Trees: Modelling and exact inference for discrete time series

Maria Skoularidou, Ioannis Kontoyiannis · OpenReview

TL;DR

This paper introduces a novel Bayesian framework called Bayesian Context Trees (BCT) for modeling discrete time series with variable memory. The authors provide efficient algorithms for exact inference, model selection, and prediction, outperforming existing methods on various real-world datasets.

What Problem Does This Paper Address?

Modeling discrete time series with complex temporal dependencies is a significant challenge. Traditional higher-order Markov chains suffer from an exponentially growing parameter space, making them inflexible and difficult to use. Existing variable-memory models, while more flexible, often lack efficient inference methods or struggle with model selection. This paper addresses the need for a principled, flexible, and computationally efficient framework for modeling and analyzing discrete time series with complex, context-dependent temporal structures.

Methods

The core of this work lies in the Bayesian Context Tree (BCT) framework. This approach models variable-memory Markov chains using tree structures, where the memory length can adapt to the observed data. The authors introduce three key algorithms:

  • Context Tree Weighting (CTW): An algorithm that efficiently computes the prior predictive likelihood exactly. This is crucial for Bayesian inference as it avoids the need to explicitly sum over all possible models.
  • Bayesian Context Tree (BCT): An algorithm that identifies the single most probable model (MAP) given the data. This is a generalization of existing context tree maximization algorithms.
  • k-BCT: An extension of BCT that identifies the top k most probable models. This allows for a more nuanced understanding of model uncertainty.

These algorithms are deterministic and have linear-time complexity with respect to the data length and maximum context depth. Additionally, a family of variable-dimension Markov Chain Monte Carlo (MCMC) samplers is developed to explore the posterior distribution of models and parameters, especially when dealing with multimodal posteriors.

Datasets

The paper evaluates the proposed methods on a variety of datasets:

  • Simulated data: Generated from known variable-memory Markov chains, including a renewal process and a third-order binary chain.
  • Real-world data:
    • Financial data: Daily changes in the S&P 500 index and Facebook stock prices.
  • Genetics: SARS-CoV-2 genome sequence.
  • Neuroscience: Neural spike train data.
  • Animal communication: Pewee birdsong.

The paper does not introduce new benchmark datasets but rather uses existing ones to compare its methods against established approaches.

Key Insights and Ideas

  • Exact Inference is Achievable: The paper demonstrates that exact Bayesian inference (computing prior predictive likelihoods and posterior probabilities) is feasible for variable-memory Markov chains, a feat often considered computationally intractable.
  • Context Trees as a Powerful Representation: The tree structure elegantly captures variable memory, allowing the model to adapt its memory length based on the observed data patterns. This is more flexible than fixed-order Markov chains.
  • Model Averaging via CTW: The CTW algorithm's ability to compute the prior predictive likelihood allows for implicit model averaging, which is a more robust approach than selecting a single "best" model.
  • k-BCT for Uncertainty Quantification: Identifying the top k models, rather than just the single best one, provides valuable insights into the uncertainty surrounding model selection.
  • Linear Time Complexity is a Game-Changer: The linear time complexity of the core algorithms makes them scalable to large datasets, a significant advantage over many existing methods.

Key Results

  • Superior Model Selection: BCT and k-BCT consistently outperformed VLMC, MTD, and MTDg models in terms of model fit (AIC/BIC scores) on simulated and real-world data. For instance, on simulated data, BCT achieved a log-loss approximately 1.6% lower than the second-best method.
  • Efficient Inference: The CTW, BCT, and k-BCT algorithms have linear-time complexity in the data length and maximum depth, making them practical for large datasets.
  • Accurate Prediction: The BCT predictor, leveraging exact Bayesian model averaging and sequential updates, demonstrated superior predictive performance, achieving lower log-loss values compared to other methods.
  • Interpretability: The learned context trees provide interpretable insights into the temporal dependencies within the data, as demonstrated in the analysis of the SARS-CoV-2 genome and pewee birdsong.

Limitations and Future Work

  • Alphabet Size: The paper notes that the main practical limitation of these tools arises when the alphabet size is large, as the complexity of the algorithms can increase.
  • Generalization to Real/Vector-Valued Data: While the current work focuses on discrete-valued time series, the authors suggest that the ideas and techniques can be generalized to real- or vector-valued observations.
  • Extension to Hidden Models: Future research directions include extending the exact inference algorithms to various types of tree-structured autoregressive models and developing tools for inference with hidden Bayesian context trees.

Summary updated

BibTeX
@misc{skoularidou2020bayesian,
  author = {Maria Skoularidou and Ioannis Kontoyiannis},
  title = {{Bayesian Context Trees: Modelling and exact inference for discrete time series}},
  year = {2020},
  eprint = {2007.14900},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2007.14900},
}
Figure