RegimeSwitchingLinearSSM#

class cultivars.state_space.regime_switching.RegimeSwitchingLinearSSM(*, design, obs_cov, transition, state_cov, regime_transition, obs_intercept=None, state_intercept=None, initial_state=None, initial_state_cov=None, initial_regime_prob=None)[source]#

A linear-Gaussian state space whose system matrices switch by regime.

The continuous-state half of the regime-switching layer – the _MarkovSwitchingStateSpace docstring’s promised extension. Each regime \(j\) of a \(K\)-state Markov chain carries its own linear-Gaussian system:

y_t         = Z_j alpha_t + d_j + eps_t,   eps_t ~ N(0, H_j)
alpha_{t+1} = T_j alpha_t + c_j + eta_t,   eta_t ~ N(0, Q_j)

Exact filtering requires tracking every regime path – \(K^t\) Kalman filters by period \(t\) – so Kim (1994) collapses: run the \(K \times K\) per-pair Kalman updates, mix by the Hamilton regime probabilities, and collapse each regime’s mixture back to one moment pair by moment matching. The likelihood is therefore an approximation, and is labeled one; it is exact in the two limits that matter for verification – identical regimes (it is the Kalman filter) and no state persistence (it is the Hamilton filter) – and the build measures its gap against brute-force path enumeration where that is affordable.

Missing observations are numpy.nan rows: the update is skipped and regime probabilities evolve by the chain alone.

See also

Attributes#

k_endog

Observation dimension.

k_regimes

Number of regimes.

k_states

State dimension.

regime_transition

The row-stochastic regime chain matrix \(P\), as a copy.

Methods#

filter(y)

Kim's (1994) approximate forward pass.

loglikelihood(y)

The collapse-approximate log-likelihood.

smooth(y)

Kim's backward pass over the regime probabilities.