MarkovSwitchingVARResult.probabilities#
- MarkovSwitchingVARResult.probabilities(kind='smoothed')[source]#
Return one of the three regime posteriors.
- Parameters:
kind (
Literal['smoothed','filtered','predicted']) –"smoothed"conditions on the whole sample and dates regimes after the fact;"filtered"is the real-time view;"predicted"is the one-step-ahead forecast of the state.- Return type:
- Returns:
An array of shape
(nobs, M)whose rows sum to one.- Raises:
SpecificationError – If
kindis not one of the three.
Example
The smoothed posterior is at least as sharp as the filtered one, which is at least as sharp as the predicted one:
>>> import numpy as np >>> rng = np.random.default_rng(0) >>> s = np.repeat([0, 1, 0, 1], 100) >>> y = np.array([[-1.0, -0.5], [1.5, 1.0]])[s] + 0.4 * rng.standard_normal((400, 2)) >>> res = MarkovSwitchingVAR(y, order=1, n_regimes=2).fit(seed=0) >>> kinds = ("smoothed", "filtered", "predicted") >>> sharp = [res.probabilities(kind).max(axis=1).mean() for kind in kinds] >>> bool(sharp[0] >= sharp[1] >= sharp[2]) True >>> bool(np.allclose(res.probabilities().sum(axis=1), 1.0)) True >>> res.probabilities("viterbi") Traceback (most recent call last): cultivars.exceptions.SpecificationError: kind must be one of ('smoothed', ...