HamiltonFilterResult#
- class cultivars.state_space.regime_switching.HamiltonFilterResult(*, loglikelihood, loglikelihood_contributions, filtered_prob, predicted_prob)[source]#
Output of the Hamilton forward filter.
For a regime \(S_t\) on \(K\) states with transition matrix \(P_{ij} = \Pr(S_t = j \mid S_{t-1} = i)\) and regime-conditional densities \(f_j(y_t) = p(y_t \mid S_t = j, y_{1:t-1})\), the filter carries two probability vectors,
\[\xi_{t \mid t-1}(j) = \Pr(S_t = j \mid y_{1:t-1}), \qquad \xi_{t \mid t}(j) = \Pr(S_t = j \mid y_{1:t}),\]held in
predicted_probandfiltered_prob. Each step is a prediction through the chain followed by Bayes’ rule,\[\xi_{t \mid t-1} = P^\top \xi_{t-1 \mid t-1}, \qquad \xi_{t \mid t}(j) = \frac{\xi_{t \mid t-1}(j)\, f_j(y_t)} {\sum_{k=1}^{K} \xi_{t \mid t-1}(k)\, f_k(y_t)},\]and the denominator is the one-step predictive density of \(y_t\), so the log likelihood is the sum of its logs over the sample.
- Variables:
filtered_prob (
NDArray[double]) – Contemporaneous regime probabilities \(\Pr(S_t = j \mid y_{1:t})\), shape(T, K).predicted_prob (
NDArray[double]) – One-step-ahead regime probabilities \(\Pr(S_t = j \mid y_{1:t-1})\), shape(T, K).loglikelihood (
float) – Total log-likelihood \(\sum_t \log \Pr(y_t \mid y_{1:t-1})\).loglikelihood_contributions (
NDArray[double]) – Per-period contributions, shape(T,).
See also
HamiltonFilterResult– the public name of this class.MarkovSwitchingSSM.filter()– returns an instance.MarkovSwitchingSSM.filter_densities()– returns an instance._hamilton_filter()– returns an instance._MarkovSwitchingStateSpace.filter()– returns an instance.
Attributes#
Contemporaneous regime probabilities \(\Pr(S_t = j \mid y_{1:t})\), shape |
|
One-step-ahead regime probabilities \(\Pr(S_t = j \mid y_{1:t-1})\), shape |
|
Total log-likelihood of the data under the model. |
|
Per-period contributions, shape |