Markets aren't one stationary thing โ they're a sequence of different weathers.
Think of a weather system that only ever has two states โ calm or stormy โ and never announces which one it's in. All you can see is today's weather. A regime model watches the recent pattern and constantly updates its best guess of "how likely is it stormy right now," so the portfolio can lean more defensive the moment the odds shift, instead of waiting for an official announcement that never comes.
The core idea โ that a hidden, unobservable state quietly governs what you *can* observe โ traces back to Andrei Markov, a Russian mathematician who introduced "Markov chains" in 1906. His first real application wasn't finance or physics at all: he counted vowels and consonants letter-by-letter through Pushkin's poem "Eugene Onegin" by hand, showing that which letter comes next depends on the current one, not the whole history before it โ the same "memoryless" idea this app uses to model Calm and Stressed markets today.
Markov chains alone weren't enough โ his states were directly observable (you can literally see the next letter). The genuinely hidden part came later: in the late 1960s, Leonard Baum and colleagues at the Institute for Defense Analyses worked out how to infer a hidden state you can never directly see, only its effects โ and how to fit the whole model from data alone (the "Baum-Welch algorithm"). That breakthrough powered speech recognition for two decades before quantitative finance adopted the same math to infer whether markets are quietly shifting regime.
Most portfolio math quietly assumes returns are drawn from one stable statistical distribution over time. Real markets aren't like that: volatility clusters, correlations spike together in crises, and calm multi-year stretches give way abruptly to stressed ones. A single long-run average smooths right over this โ it tells you what markets look like "on average," which is a regime that basically never actually occurs on any given day.
A Hidden Markov Model assumes returns are generated by a small number of latent "regimes" (typically two โ calm and stressed) each with its own volatility and correlation behaviour, with some probability of switching between them each period. The regime itself is never directly observed โ it's inferred from the data using the forward-backward algorithm, fit via Expectation-Maximization, producing a probability of being in each regime right now, updated as new data arrives.
A is the transition matrix (how sticky each regime is). Each regime k
has its own return distribution โ calm regimes are tight and quiet, stressed regimes are
wide and volatile.
Illustrative โ the model's estimated probability of being in the "stressed" regime, day by day, with the shaded band marking where it crosses 50%.
The Regime tab runs this live, and its output feeds both the Ledoit-Wolf target and the Robust SOCP uncertainty budget โ the "stressed" probability widens the robustness budget automatically. Regime persistence (how sticky a detected regime is) was specifically tuned so the model doesn't flicker between states on noise; real persistence now runs in the high 90s% once a regime is established.
An HMM recognises a regime shift by its statistical fingerprint โ a shift in volatility and correlation that resembles a pattern it has effectively learned from history. It does not predict a genuinely novel shock before it happens; it tells you where you are once the data starts moving, not what's about to happen next. It's a mirror held up to the present, not a window into the future.
General education only. Nothing here is personal financial advice or takes into account your objectives, financial situation or needs. Past performance is not a guarantee of future results.