KimFilterResult#

class cultivars.state_space.regime_switching.KimFilterResult(*, loglikelihood, loglikelihood_contributions, filtered_prob, predicted_prob, filtered_state, filtered_state_cov, regime_state)[source]#

Output of the Kim (1994) regime-switching Kalman forward pass.

In a state-space model whose system matrices depend on a Markov regime, the exact filter would have to track one Gaussian per regime history, which is \(K^t\) components after \(t\) periods. Kim’s (1994) filter keeps \(K\) of them. At each date it runs the \(K \times K\) Kalman updates from every regime-\(i\) posterior into every regime \(j\), weights them by Hamilton’s recursion, and then collapses over the origin regime by moment matching,

\[a^{j}_{t \mid t} = \frac{\sum_{i=1}^{K} \Pr(S_{t-1} = i, S_t = j \mid y_{1:t})\, a^{(i,j)}_{t \mid t}}{\Pr(S_t = j \mid y_{1:t})},\]

with the matching expression for the covariance, which adds the spread of the \(a^{(i,j)}_{t \mid t}\) around \(a^{j}_{t \mid t}\). The collapse is the approximation: the result is exact only when the regime does not affect the state law.

filtered_prob and predicted_prob are the regime probabilities, regime_state the per-regime collapsed states \(a^{j}_{t \mid t}\), and filtered_state with filtered_state_cov their mixture over regimes, \(\sum_j \Pr(S_t = j \mid y_{1:t})\, a^{j}_{t \mid t}\).

Variables:
  • filtered_prob (NDArray[double]) – Contemporaneous regime probabilities, (n, K).

  • predicted_prob (NDArray[double]) – One-step-ahead regime probabilities, (n, K).

  • filtered_state (NDArray[double]) – Regime-marginal filtered state means, (n, m).

  • filtered_state_cov (NDArray[double]) – Regime-marginal filtered covariances, (n, m, m) – mixture covariances, including the between-regime spread.

  • regime_state (NDArray[double]) – Per-regime collapsed state means, (n, K, m).

See also

Attributes#

filtered_prob

Contemporaneous regime probabilities, (n, K).

predicted_prob

One-step-ahead regime probabilities, (n, K).

filtered_state

Regime-marginal filtered state means, (n, m).

filtered_state_cov

Regime-marginal filtered covariances, (n, m, m) -- mixture covariances, including the between-regime spread.

regime_state

Per-regime collapsed state means, (n, K, m).

loglikelihood

Total log-likelihood of the data under the model.

loglikelihood_contributions

Per-period contributions, shape (n,).