Tutorials › Stochastic Processes › Diagnosing Baum-Welch Fits with Restarts and Likelihood Traces

Hidden Markov Models · Tutorial 957 of 994

Diagnosing Baum-Welch Fits with Restarts and Likelihood Traces

Use multiple starts, likelihood traces, probability checks, and posterior occupancy to diagnose unstable or degenerate Baum-Welch fits.

Advanced 12 min read

What You'll Learn

  • Compare restart likelihoods while accounting for label switching.
  • Interpret nondecreasing likelihood traces and identify suspicious decreases.
  • Check initial, transition, and emission probabilities against their constraints.
  • Compute expected state occupancy from smoothed posterior probabilities.
  • Distinguish a low-occupancy state from evidence that a model is globally optimal.
  • Use concrete diagnostics to decide which fits need investigation or rerunning.

Why a Single Baum-Welch Fit Is Not Enough

Baum-Welch uses the expectation-maximization algorithm to improve an HMM parameter estimate, but it does not guarantee that different initial parameters lead to the same fit. The observed-data likelihood can have multiple local maxima, and some runs can leave a state with almost no posterior support. A useful diagnosis therefore compares several initializations, inspects each likelihood trace, and checks whether the fitted parameters still define valid probability distributions.

Let \((\Omega,\mathcal{F},\mathbb{P})\) be a probability space. Consider a discrete-time hidden Markov model with hidden process \((X_t)_{1\le t\le T}\) on a finite state space \(S=\{1,\ldots,K\}\), and observations \(Y_1,\ldots,Y_T\) in a finite alphabet \(\mathcal{Y}\). Its parameters are an initial row distribution \(\pi\), a row-stochastic transition matrix \(P=(p_{ij})\), and emission probabilities \(b_j(y)=\mathbb{P}(Y_t=y\mid X_t=j)\). The observed-data likelihood for a fixed sequence \(y_{1:T}\) is \(L(\theta)=\mathbb{P}_{\theta}(Y_1=y_1,\ldots,Y_T=y_T)\), where \(\theta=(\pi,P,b)\). When \(L(\theta)>0\), the log-likelihood is \(\ell(\theta)=\log L(\theta)\).

Definition: A restart is a separate Baum-Welch run initialized at a different admissible parameter value. Its likelihood trace is the sequence \(\ell(\theta^{(0)}),\ell(\theta^{(1)}),\ldots\) evaluated after successive parameter updates on the same observed data. The smoothed state probability is \(\gamma_t(j)=\mathbb{P}_{\theta}(X_t=j\mid Y_1=y_1,\ldots,Y_T=y_T)\), when the conditioning event has positive probability. The expected occupancy of state \(j\) is \(N_j=\sum_{t=1}^T\gamma_t(j)\).

For categorical emissions, an admissible parameter must satisfy \(\pi_j\ge0\), \(\sum_j\pi_j=1\), \(p_{ij}\ge0\), \(\sum_jp_{ij}=1\) for every state \(i\), and \(b_j(y)\ge0\), \(\sum_{y\in\mathcal{Y}}b_j(y)=1\) for every state \(j\). In a Gaussian-emission HMM, the emission parameters instead need to satisfy the conditions of the chosen Gaussian model, including positive variance or a positive-definite covariance matrix. These checks are separate from asking whether the likelihood is large.

What a Likelihood Trace Can and Cannot Say

For an exact Baum-Welch update with a well-defined E-step and M-step, the observed-data likelihood does not decrease. This monotonicity result was established in the earlier material on why Baum-Welch does not decrease likelihood. Consequently, a substantial decrease in a computed trace is a warning to inspect the implementation, the likelihood calculation, and the update being used. Small decreases can also arise from rounding or approximate updates, so the numerical tolerance and implementation should be checked before concluding that the model is wrong.

A nondecreasing trace does not show that the run has found a global maximum. Nor does a flat trace alone prove convergence to a useful fit: parameters can still be changing in directions that barely affect the likelihood, or the model can have redundant states. The fitted likelihoods across restarts provide evidence about sensitivity to initialization, not a proof of global optimality. If two runs have different likelihoods, prefer the larger likelihood only after confirming both runs used the same data, model, and likelihood convention.

Result (State relabeling leaves the likelihood unchanged): If the hidden-state labels are permuted consistently in the initial distribution, transition matrix, and emission parameters, the likelihood of every observation sequence remains the same.

Proof. Write the likelihood as a sum over all hidden paths \(x_{1:T}\in S^T\): each summand is \(\pi_{x_1}b_{x_1}(y_1)\prod_{t=2}^T p_{x_{t-1}x_t}b_{x_t}(y_t)\). A permutation of \(S\) is a bijection from the set of paths \(S^T\) to itself. Under consistent relabeling, the summand for a path equals the original summand for its inverse-permuted path, since every initial, transition, and emission factor is unchanged apart from its state index. Reindexing the finite sum by this bijection gives the same likelihood. This also covers \(T=1\), where the transition product is empty, and \(K=1\), where the only permutation is the identity. \(\square\)

This label symmetry matters when interpreting restarts. Two fits can describe the same statistical model while assigning different names to the states. Compare likelihoods and state characteristics after accounting for relabeling; do not treat a mere swap of state labels as evidence of instability.

Worked Example: Comparing a Short Likelihood Trace

For one binary observation \(y=1\), consider a two-state HMM with transition matrix \(P=\begin{bmatrix}1&0\\0&1\end{bmatrix}\). Each row sums to \(1\). The transition matrix does not affect a length-one likelihood. At three parameter snapshots, the initial probabilities and the probabilities of observing \(1\) in each state are as follows. All values lie in \([0,1]\), and the complementary emission probabilities for observing \(0\) are obtained by subtracting from \(1\).

At snapshot 0, \(\pi=(\tfrac12,\tfrac12)\) and \((b_1(1),b_2(1))=(\tfrac14,\tfrac34)\). The likelihood is \(\tfrac12\cdot\tfrac14+\tfrac12\cdot\tfrac34=\tfrac12\). At snapshot 1, \(\pi=(\tfrac14,\tfrac34)\) and \((b_1(1),b_2(1))=(\tfrac12,\tfrac56)\), giving \(\tfrac14\cdot\tfrac12+\tfrac34\cdot\tfrac56=\tfrac18+\tfrac58=\tfrac34\). At snapshot 2, \(\pi=(\tfrac13,\tfrac23)\) and \((b_1(1),b_2(1))=(\tfrac23,1)\), giving \(\tfrac13\cdot\tfrac23+\tfrac23\cdot1=\tfrac29+\tfrac69=\tfrac89\).

$$ L(\theta^{(0)})=\tfrac12,\qquad L(\theta^{(1)})=\tfrac34,\qquad L(\theta^{(2)})=\tfrac89. $$

Check: Since the logarithm is strictly increasing on positive numbers, the likelihood trace is nondecreasing exactly when its log-likelihood trace is nondecreasing. Here \(\tfrac12<\tfrac34<\tfrac89\), so the corresponding log-likelihoods increase. This calculation illustrates how to audit reported trace values; it does not claim that these snapshots are generated by a particular Baum-Welch update.

Checking Expected State Occupancy

The forward-backward smoothing probabilities give a direct diagnostic for weakly used states. At each time \(t\), the probabilities \(\gamma_t(j)\) sum to one, provided the observation sequence has positive likelihood. Summing over time gives \(N_j\), the expected number of visits to state \(j\) conditional on the observed data. The occupancy fraction \(N_j/T\) lies between zero and one. A very small fraction can indicate that a state is effectively unused in this fitted run, but it does not by itself show that the state is unnecessary for the scientific problem or that another model size is preferable.

Result (Occupancies sum to the sequence length): If \(L(\theta)>0\), then \(\sum_{j\in S}N_j=T\). In particular, every \(N_j\) is nonnegative and no occupancy exceeds \(T\).

Proof. Positive likelihood makes the conditional probabilities defining \(\gamma_t(j)\) meaningful. For each fixed \(t\), the events \(\{X_t=j\}\), \(j\in S\), are disjoint and their union is the whole hidden-state space. Therefore \(\sum_{j\in S}\gamma_t(j)=1\). Summing this equality over \(t=1,\ldots,T\) and interchanging two finite sums gives \(\sum_{j\in S}N_j=\sum_{t=1}^T\sum_{j\in S}\gamma_t(j)=\sum_{t=1}^T1=T\). Nonnegativity follows because conditional probabilities are nonnegative; hence \(N_j\le T\) as well. \(\square\)

Worked Example: Detecting a Nearly Empty State

Take \(S=\{1,2\}\), \(T=2\), initial distribution \(\pi=(\tfrac12,\tfrac12)\), and \(P=\begin{bmatrix}1&0\\0&1\end{bmatrix}\). Each transition row sums to \(1\), so the chain remains in its initial state. Let the observed sequence be \(y_1=y_2=1\), with \(b_1(1)=\tfrac34\) and \(b_2(1)=\tfrac14\). The complementary probabilities for \(0\) are \(\tfrac14\) and \(\tfrac34\), so both emission distributions are normalized.

The only possible hidden paths are \((1,1)\) and \((2,2)\). Their joint probabilities with the observations are \(\tfrac12(\tfrac34)(\tfrac34)=\tfrac9{32}\) and \(\tfrac12(\tfrac14)(\tfrac14)=\tfrac1{32}\). Thus the observation likelihood is \(\tfrac9{32}+\tfrac1{32}=\tfrac{10}{32}=\tfrac5{16}>0\). Conditional on the observations, the probability of path \((1,1)\) is \((\tfrac9{32})/(\tfrac{10}{32})=\tfrac9{10}\); the probability of path \((2,2)\) is \(\tfrac1{10}\). At each time, therefore, \(\gamma_t(1)=\tfrac9{10}\) and \(\gamma_t(2)=\tfrac1{10}\).

The occupancies are \(N_1=\tfrac9{10}+\tfrac9{10}=\tfrac95\) and \(N_2=\tfrac1{10}+\tfrac1{10}=\tfrac15\). The fractions of expected occupancy are \(\tfrac{N_1}{T}=\tfrac9{10}\) and \(\tfrac{N_2}{T}=\tfrac1{10}\). Check: \(\tfrac95+\tfrac15=2=T\), as required. State 2 has lower posterior occupancy in this fit, which is a reason to inspect it alongside other diagnostics, not a standalone decision to remove it.

Probability Constraints and Restart Comparisons

Constraint checks should be performed on the actual fitted parameters, not inferred from the likelihood trace. For a categorical HMM, inspect the initial vector, every transition row, and every emission distribution. Negative entries, a row sum different from one, or a non-finite value mean the fitted object is not an admissible probability model, even if a software routine returned a score. If parameters are rounded for display, check the unrounded values when possible; displayed row sums can differ slightly because of rounding.

Worked Example: Finding an Invalid Transition Row

Suppose a two-state fit reports \(\pi=(\tfrac25,\tfrac35)\) and \(P=\begin{bmatrix}\tfrac34&\tfrac14\\\tfrac13&\tfrac12\end{bmatrix}\). The initial probabilities sum to \(\tfrac25+\tfrac35=1\). The first transition row sums to \(\tfrac34+\tfrac14=1\), but the second sums to \(\tfrac13+\tfrac12=\tfrac56\), not \(1\). Thus this reported matrix is not row-stochastic and cannot be used as a valid transition matrix.

One must not silently repair it while retaining the original likelihood trace: renormalizing the second row changes the model parameters and can change the likelihood. If renormalization is deliberately part of a correction, its new row would be \((\tfrac{1/3}{5/6},\tfrac{1/2}{5/6})=(\tfrac25,\tfrac35)\), and the likelihood must then be recomputed for the corrected model.

Check: The corrected row sums to \(\tfrac25+\tfrac35=1\). The correction produces a valid row but is a new parameter value, so it is not evidence that the original fit was valid.

For multiple restarts, record at least the final log-likelihood, the trace behavior, constraint-check results, and state occupancies. Compare all runs on the same data and under the same likelihood convention. If several runs reach comparable high likelihoods but their parameters differ substantially after matching state labels, report that sensitivity rather than selecting a single run without qualification. If one run has clearly lower likelihood, verify that its trace and constraints are sound before treating it as an inferior local solution.

Common mistake. A frequent error is to regard a nondecreasing trace as proof that the fit is valid and globally optimal. For example, the sequence of reported likelihoods \(\tfrac12,\tfrac34,\tfrac89\) increases, but the invalid transition matrix in the previous example still fails the row-sum condition. Monotonicity checks the direction of likelihood change, not whether the parameters define a probability model, whether the computation is correct, or whether another initialization reaches a better solution. Check these issues separately.

A practical diagnosis therefore asks three different questions: did the likelihood behave as expected; do the fitted parameters satisfy their probability constraints; and are all states meaningfully represented in the smoothed posterior occupancy? Agreement across these checks and across restarts supports a stable fit, but it does not establish that the model is scientifically appropriate. Interpretation still depends on the application and the assumptions built into the HMM.

Check Your Understanding

For each question, distinguish a numerical warning from a conclusion that the model itself is unsuitable.

  1. Why can two restarts have different state-specific parameter estimates but the same likelihood?
  2. A reported transition row is \((\tfrac14,\tfrac12)\). Does it satisfy the row-stochastic constraint? Show the row sum.
  3. For a sequence of length \(T=5\), smoothed probabilities for one state sum to \(\tfrac14+\tfrac12+\tfrac34+\tfrac12+\tfrac14\). Compute its expected occupancy and occupancy fraction.
  4. What does a decrease in an exact Baum-Welch likelihood trace suggest, and why should small numerical decreases be treated cautiously?
  5. Why is a low expected occupancy a diagnostic signal rather than, by itself, proof that a state should be removed?