A Hidden Markov Model (HMM) assumes that an observable time series — such as daily equity returns — is generated by a hidden state process that evolves as a first-order Markov chain. The next state depends only on the current state, not on the full history. The hidden states are latent: not directly observed, but inferred from the data.
For financial time series, two- or three-state HMMs are commonly used to distinguish market regimes, such as:
- Low-volatility, trending (risk-on, positive drift)
- High-volatility, mean-reverting or bear (risk-off, negative drift or elevated vol)
Parameters estimated by the EM algorithm
- State transition probabilities — how likely is a regime switch at each step?
- Emission parameters for each state — mean return and variance in each regime
Once fitted, the Viterbi algorithm decodes the most probable hidden-state sequence. This regime series is used to condition signal behavior: a momentum signal may be active in trending regimes but switched off in mean-reverting or risk-off regimes where it historically loses money.