Skip to main content

Detecting renewal states in chains of variable length via intrinsic Bayes factors


Markov chains with variable length are useful parsimonious stochastic models able to generate most stationary sequence of discrete symbols. The idea is to identify the suffixes of the past, called contexts, that are relevant to predict the future symbol. Sometimes a single state is a context, and looking at the past and finding this specific state makes the further past irrelevant. States with such property are called renewal states and they can be used to split the chain into independent and identically distributed blocks. In order to identify renewal states for chains with variable length, we propose the use of Intrinsic Bayes Factor to evaluate the hypothesis that some particular state is a renewal state. In this case, the difficulty lies in integrating the marginal posterior distribution for the random context trees for general prior distribution on the space of context trees, with Dirichlet prior for the transition probabilities, and Monte Carlo methods are applied. To show the strength of our method, we analyzed artificial datasets generated from different models and one example coming from the field of Linguistics.

This is a preview of subscription content, access via your institution.

Fig. 1
Fig. 2
Fig. 3
Fig. 4
Fig. 5
Fig. 6
Fig. 7
Fig. 8
Fig. 9


  • Aitkin, M.: Posterior bayes factors. J. R. Stat. Soc. Ser. B (Methodol.) 53(1), 111–128 (1991)

    MATH  Google Scholar 

  • Aitkin, M.: Posterior Bayes factor analysis for an exponential regression model. Stat. Comput. 3(1), 17–22 (1993)

    Article  Google Scholar 

  • Aitkin, M., Finch, S., Mendell, N., et al.: A new test for the presence of a normal mixture distribution based on the posterior Bayes factor. Stat. Comput. 6(2), 121–125 (1996)

    Article  Google Scholar 

  • Balding, D., Ferrari, P.A., Fraiman, R., et al.: Limit theorems for sequences of random trees. Test 18(2), 302–315 (2009)

    Article  MathSciNet  MATH  Google Scholar 

  • Berger, J.O., Pericchi, L.R.: The intrinsic Bayes factor for model selection and prediction. J. Am. Stat. Assoc. 91(433), 109–122 (1996)

    Article  MathSciNet  MATH  Google Scholar 

  • Berger, J.O., Bernardo, J.M., Sun, D.: Overall objective priors. Bayesian Anal. 10(1), 189–221 (2015)

    Article  MathSciNet  MATH  Google Scholar 

  • Bühlmann, P., Wyner, A.J.: Variable length Markov chains. Ann. Stat. 27(2), 480–513 (1999)

    Article  MathSciNet  MATH  Google Scholar 

  • Busch, J.R., Ferrari, P.A., Flesia, A.G., et al.: Testing statistical hypothesis on random trees and applications to the protein classification problem. Ann. Appl. Stat. 3(2), 542–563 (2009)

    Article  MathSciNet  MATH  Google Scholar 

  • Cabras, S., Castellanos, M.E., Perra, S.: A new minimal training sample scheme for intrinsic Bayes factors in censored data. Comput. Stat. Data Anal. 81, 52–63 (2015)

    Article  MathSciNet  MATH  Google Scholar 

  • Charitidou, E., Fouskakis, D., Ntzoufras, I.: Objective Bayesian transformation and variable selection using default Bayes factors. Stat. Comput. 28(3), 579–594 (2018)

    Article  MathSciNet  MATH  Google Scholar 

  • Chib, S., Greenberg, E.: Understanding the Metropolis–Hastings algorithm. Am. Stat. 49(4), 327–335 (1995)

    Google Scholar 

  • Csiszár, I., Talata, Z.: Context tree estimation for not necessarily finite memory processes, via BIC and MDL. IEEE Trans. Inf. Theory 52(3), 1007–1016 (2006)

    Article  MathSciNet  MATH  Google Scholar 

  • Dimitrakakis, C.: Bayesian variable order Markov models. In: Proceedings of the Thirteenth International Conference on Artificial Intelligence and Statistics, JMLR Workshop and Conference Proceedings, pp. 161–168 (2010)

  • Galves, A, Löcherbach, E.: Stochastic chains with memory of variable length. In: Grünwald et al. (eds.) Festschrift for Jorma Rissanen, TICSP Series, vol. 38, pp. 117–133 (2008)

  • Galves, C., Moraes, M.A.T., Ribeiro, I.: Syntax and morphology in the placement of clitics in European and Brazilian Portuguese. J. Port. Linguist. 4(2) (2005)

  • Galves, A., Galves, C., Garcia, J.E., et al.: Context tree selection and linguistic rhythm retrieval from written texts. Ann. Appl. Stat. 6(1), 186–209 (2012)

    Article  MathSciNet  MATH  Google Scholar 

  • Hastings, W.K.: Monte carlo sampling methods using Markov chains and their applications. Biometrika (1970)

  • Kass, R.E., Raftery, A.E.: Bayes factors. J. Am. Stat. Assoc. 90(430), 773–795 (1995)

    Article  MathSciNet  MATH  Google Scholar 

  • Kennel, M.B., Mees, A.I.: Context-tree modeling of observed symbolic dynamics. Phys. Rev. E 66(5), 056209 (2002)

    Article  MathSciNet  Google Scholar 

  • Kontoyiannis, I., Mertzanis, L., Panotopoulou, A. et al.: Bayesian context trees: modelling and exact inference for discrete time series. J. R. Stat. Soc. Ser. B (Methodol.) 1–37 (2022)

  • Madigan, D., York, J., Allard, D.: Bayesian graphical models for discrete data. Int. Stat. Rev./Rev. Int. de Stat. 215–232 (1995)

  • O’Hagan, A.: Fractional Bayes factors for model comparison. J. R. Stat. Soc. Ser. B (Methodol.) 57(1), 99–118 (1995)

    MathSciNet  MATH  Google Scholar 

  • Rissanen, J.: A universal data compression system. IEEE Trans. Inf. Theory 29(5), 656–664 (1983)

    Article  MathSciNet  MATH  Google Scholar 

  • Ron, D., Singer, Y., Tishby, N.: The power of amnesia: learning probabilistic automata with variable memory length. Mach. Learn. 25(2), 117–149 (1996)

    Article  MATH  Google Scholar 

  • Smith, W.L.: Regenerative stochastic processes. Proc. R. Soc. Lond. A 232(1188), 6–31 (1955)

    Article  MathSciNet  MATH  Google Scholar 

  • Steuer, R., Ebeling, W., Russell, D., et al.: Entropy and local uncertainty of data from sensory neurons. Phys. Rev. E 64(6), 061911 (2001)

    Article  Google Scholar 

  • Villa, C., Walker, S.G.: An objective Bayes factor with improper priors. Comput. Stat. Data Anal. 107404 (2021)

  • Willems, F.M., Shtarkov, Y.M., Tjalkens, T.J.: The context-tree weighting method: basic properties. IEEE Trans. Inf. Theory 41(3), 653–664 (1995)

    Article  MATH  Google Scholar 

  • Xiong, J., Jääskinen, V., Corander, J.: Recursive learning for sparse Markov models. Bayesian Anal. 11(1), 247–263 (2016)

Download references


This work was funded by Fundação de Amparo à Pesquisa do Estado de São Paulo - FAPESP Grants 2017/25469-2 and 2017/10555-0, CNPq Grant 304148/2020-2 and by Coordenação de Aperfeiçoamento de Pessoal de Nível Superior - Brasil (CAPES) - Finance Code 001. We thank Helio Migon and Alexandra Schmidt for fruitful discussions.

Author information

Authors and Affiliations


Corresponding author

Correspondence to Victor Freguglia.

Ethics declarations

Conflict of interest

The authors declare that they have no conflict of interest.

Additional information

Publisher's Note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Supplementary Information

Below is the link to the electronic supplementary material.

Supplementary file 1 (zip 20 KB)


Simulation results

We present the distribution of the PBF values used to compute the GIBF results in the simulation studies from Sect. 4 in Figs. 891011 and  12. Each point represents one PBF computed in \(\log _{10}\) scale, with black points being considered in both 10%-trimmed and untrimmed results, while light-gray points are not considered for in the trimmed GIBF value.

Fig. 10
figure 10

Distribution of computed PBF values for algorithm runs on simulations using Model 3

Fig. 11
figure 11

Distribution of computed PBF values for algorithm runs on simulations using Model 4

Fig. 12
figure 12

Distribution of computed PBF values for algorithm runs on simulations using Model 5

Figure 11 is a good example of why the arithmetic mean of PBFs (AIBF) may be very unstable, as even in the trimming version a few values may be as high as \(10^5\), which completely dominates the arithmetic mean (we recall that at most 100 values are used in the average), not taking into account the fact that most values are lower than \(10^{-5}\) (evidence against the renewal hypothesis).

Application results

We present the distribution of the PBF values used to compute the GIBF results in the simulations from Sect. 5 in Fig. 13. The interpretation of the black and light-gray points are the same as in “Appendix B”, but the trimming considered is 5% as specified in the application description.

Fig. 13
figure 13

Distribution of computed PBF values for algorithm runs for the application dataset

Rights and permissions

Springer Nature or its licensor (e.g. a society or other partner) holds exclusive rights to this article under a publishing agreement with the author(s) or other rightsholder(s); author self-archiving of the accepted manuscript version of this article is solely governed by the terms of such publishing agreement and applicable law.

Reprints and Permissions

About this article

Verify currency and authenticity via CrossMark

Cite this article

Freguglia, V., Garcia, N.L. Detecting renewal states in chains of variable length via intrinsic Bayes factors. Stat Comput 33, 21 (2023).

Download citation

  • Received:

  • Accepted:

  • Published:

  • DOI:


  • Variable length Markov Chains
  • Renewal states
  • Bayes factor
  • Intractable normalizing constant