NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Determine the Number of States in Hidden Markov Models via Marginal Likelihood

Yang Chen, Cheng–Der Fuh, Chu-Lan Michael KaoarXiv 2024 · DOI

TL;DR

This paper tackles the long-standing challenge of deciding how many hidden states exist in a Hidden Markov Model (HMM). By using a marginal likelihood approach—integrating out both hidden states and model parameters—the authors provide a method that is mathematically consistent, avoids the "infinite likelihood" traps of traditional methods, and outperforms the standard Bayesian Information Criterion (BIC) in practical simulations and real-world biological data.

What Problem Does This Paper Address?

Hidden Markov Models (HMMs) are the workhorses of time-series analysis, used in everything from speech recognition to molecular biology. A fundamental question when using them is: How many hidden states ($K$) are actually there?

This is a "model selection" problem. Traditionally, researchers use the Bayesian Information Criterion (BIC) or Akaike Information Criterion (AIC). However, these have major flaws:

  1. Unbounded Likelihood: In popular models like Gaussian HMMs with different variances (heterogeneous covariance), the likelihood function can actually go to infinity if one component "collapses" onto a single data point. This makes Maximum Likelihood Estimation (MLE)—and by extension, BIC—theoretically unstable.
  2. Inconsistency: AIC is known to overestimate the number of states even with infinite data.
  3. Non-identifiability: When you guess too many states, the parameters become "unidentifiable" (many different parameter settings yield the same result), which breaks the standard regularity conditions required for BIC to work.

Methods

The authors propose using the Marginal Likelihood (also known as the evidence or the normalizing constant of the posterior) to select $K$.

The Core Idea

Instead of finding the "best" parameters (MLE) and then penalizing the model's complexity (like BIC), the marginal likelihood integrates the likelihood over the entire prior distribution of parameters. This naturally incorporates a "Bayesian Occam's Razor"—complex models are automatically penalized because their prior probability mass is spread too thin.

Computational Strategy

Since the integral for marginal likelihood is usually impossible to solve analytically, the authors provide an efficient two-step computational framework:

  1. MCMC Sampling: Use Markov Chain Monte Carlo to get samples from the posterior distribution of the HMM parameters.
  2. Normalizing Constant Estimation: Use Importance Sampling (IS) or Reciprocal Importance Sampling (RIS) to estimate the marginal likelihood from those samples. They specifically recommend a "locally restricted" version to make the estimate robust against the "tails" of the distribution.

The authors also provide an R package, HMMmlselect, making the method accessible to practitioners.

Datasets

The paper validates the method using:

  • Extensive Simulations: Gaussian HMMs with various transition structures (flat, diagonal, off-diagonal) and noise levels. They tested both small ($n=200$) and large ($n=2000$) sample sizes.
  • Single-Molecule FRET Data: Real-world experimental data from protein transportation studies. These experiments track how proteins move through membranes, where the "states" correspond to different physical conformations of the molecular complex.

Key Insights and Ideas

  • Solving the Unboundedness: By incorporating a prior distribution, the marginal likelihood approach "smooths out" the singularities where the likelihood would otherwise blow up to infinity. This makes it much more robust than MLE-based methods for Gaussian HMMs.
  • The Mixture Model Connection: The authors prove that HMM state selection is a generalization of the "order selection" problem in finite mixture models. Their consistency proofs cover both cases.
  • Rigorous Consistency: The paper provides a formal proof that as you get more data, the marginal likelihood will choose the "true" number of states with probability 1. This is a significant theoretical contribution, as proving consistency for HMMs is notoriously difficult due to the dependence between observations.

Key Results

  • Superior Accuracy: In simulations with $n=200$ observations, the marginal likelihood method correctly identified the number of states significantly more often than BIC. For example, in some noisy scenarios, the marginal likelihood was correct ~80% of the time while BIC dropped to ~16%.
  • Robustness to Noise: The method maintains high accuracy even as the signal-to-noise ratio decreases (i.e., as the standard deviation $\sigma$ of the states increases).
  • Real-World Sensitivity: On FRET biological data, the marginal likelihood correctly identified three hidden states in trajectories where BIC only found two. Independent biological analysis confirmed that the third state was real but occurred rarely, proving the proposed method is more sensitive to "rare" states.

Limitations and Future Work

  • Prior Sensitivity: While the influence of the prior vanishes as the sample size $n \to \infty$, it can still affect results for very small datasets. The authors suggest data-driven "flat" priors, but choosing the "right" prior remains a subjective step.
  • Computational Cost: Running MCMC followed by Importance Sampling is computationally more expensive than running a standard EM algorithm for BIC. While feasible for most research applications, it might be slow for extremely high-dimensional or massive datasets.
  • Dirichlet Prior Gap: The authors note that while Dirichlet priors are standard and work well in their simulations, they don't strictly satisfy one of the technical conditions (Condition 7) used in their proof. Extending the formal proof to cover the Dirichlet case specifically is a suggested area for future theory work.

Summary updated

BibTeX
@misc{chen2024determine,
  author = {Yang Chen and Cheng–Der Fuh and Chu-Lan Michael Kao},
  title = {{Determine the Number of States in Hidden Markov Models via Marginal Likelihood}},
  year = {2024},
  eprint = {2405.12343},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2405.12343},
}
Figure