MarkovSwitchingDFMResult#

class cultivars.multivariate.regime_switching.markov_switching.MarkovSwitchingDFMResult(*, panel, series_names, loadings, idiosyncratic_var, phi, sigma_v, mu, regime_transition, factor, filtered_prob, smoothed_prob, means, scales, llf, n_params, converged)[source]#

A fitted switching factor model: the factor, and the regime chronology.

The Kim-Nelson model on a standardized panel \(x_t\),

\[x_{it} = \lambda_i f_t + e_{it}, \qquad f_t = \mu_{S_t} + \phi f_{t-1} + v_t, \qquad e_{it} \sim N(0, \psi_i), \quad v_t \sim N(0, \sigma_v^2),\]

with a two-state chain on the factor’s intercept and the first loading fixed at one. The record carries the parameters on the standardized scale, the filtered factor, both regime posteriors, and the standardization that was removed, so the panel can be reconstructed.

Note

llf is the Kim (1994) collapse approximation to the exact likelihood – after each update the regime-conditional state distributions are collapsed to one Gaussian per regime – and it was maximized as such. It is comparable across fits of this model on the same panel and not against an exact likelihood. The factor path is the filtered one; the regime probabilities are available both filtered and smoothed.

Variables:
  • panel – The observed (nobs, n_series) panel.

  • series_names – One label per series.

  • loadings – (n_series,) factor loadings on the standardized panel; the first is one by the identification convention.

  • idiosyncratic_var – (n_series,) idiosyncratic variances on the standardized scale.

  • phi – Factor persistence.

  • sigma_v – Factor innovation standard deviation.

  • mu – (2,) regime intercepts of the factor, low state first.

  • regime_transition – (2, 2) row-stochastic chain matrix.

  • factor – (nobs,) filtered factor estimate.

  • filtered_prob – (nobs, 2) filtered regime probabilities.

  • smoothed_prob – (nobs, 2) smoothed regime probabilities.

  • means – (n_series,) series means removed before estimation.

  • scales – (n_series,) series standard deviations divided out.

  • llf – The maximized Kim-approximate log-likelihood – the collapse approximation, reported under that name.

  • n_params – Free parameters the likelihood was maximized over.

  • converged – Whether the optimizer reported convergence.

See also

  • MarkovSwitchingDFM – the model whose fit() returns this record.

  • DFM – the factor model without the switch.

References

Kim, C.-J., & Nelson, C. R. (1998). Business cycle turning points, a new coincident index, and tests of duration dependence based on a dynamic factor model with regime switching. Review of Economics and Statistics, 80(2), 188-201.

Kim, C.-J. (1994). Dynamic linear models with Markov-switching. Journal of Econometrics, 60(1-2), 1-22.

Example

A hand-constructed record on a flat panel shows the accessors without a fit; the fitted example is on MarkovSwitchingDFM:

>>> import numpy as np
>>> res = MarkovSwitchingDFMResult(
...     panel=np.zeros((80, 3)), series_names=("ip", "emp", "sales"),
...     loadings=np.array([1.0, 0.8, 1.2]), idiosyncratic_var=np.full(3, 0.3),
...     phi=0.6, sigma_v=0.5, mu=np.array([-1.5, 0.5]),
...     regime_transition=np.array([[0.8, 0.2], [0.05, 0.95]]),
...     factor=np.zeros(80), filtered_prob=np.full((80, 2), 0.5),
...     smoothed_prob=np.tile([0.1, 0.9], (80, 1)), means=np.zeros(3),
...     scales=np.ones(3), llf=-100.0, n_params=11, converged=True,
... )
>>> res.n_series, res.nobs, res.expected_durations().round(1)
(3, 80, array([ 5., 20.]))
>>> res.recession_probabilities().shape, float(res.recession_probabilities()[0])
((80,), 0.1)

Attributes#

panel

The observed (nobs, n_series) panel as supplied, unstandardized.

series_names

One label per series, in column order.

loadings

(n_series,) loadings on the standardized panel, the first fixed at one.

idiosyncratic_var

(n_series,) idiosyncratic variances on the standardized scale.

phi

Factor persistence.

sigma_v

Factor innovation standard deviation.

mu

(2,) regime intercepts of the factor, low state first.

regime_transition

(2, 2) row-stochastic transition matrix, low state first.

factor

(nobs,) filtered factor estimate.

filtered_prob

(nobs, 2) filtered regime probabilities.

smoothed_prob

(nobs, 2) smoothed regime probabilities.

means

(n_series,) series means removed before estimation.

scales

(n_series,) series standard deviations divided out before estimation.

llf

The maximized Kim-approximate log-likelihood.

n_params

2 n_series + 5.

converged

Whether the optimizer reported convergence.

n_series

Number of series in the panel.

nobs

Panel length.

Methods#

expected_durations()

Expected regime durations 1 / (1 - p_jj), low state first.

recession_probabilities()

Smoothed probability of the low-mean regime, per period.

summary()

The estimation summary, renderable as text, HTML, or a dataframe.