MarkovSwitchingARResult._likelihood_ratio_obstacle#

MarkovSwitchingARResult._likelihood_ratio_obstacle(counterpart)[source]#

Block only the comparison that changes the number of regimes.

Unlike a threshold model, a Markov-switching model is perfectly testable against a nested specification that holds K fixed – dropping a switching block, say – because every parameter remains identified under that null. What is not testable is K itself: under the null of fewer regimes, the extra regime’s coefficients are free to take any value and the transition probabilities into it sit on the boundary at zero, so the statistic is neither chi-squared nor even pivotal. A result that is not a Markov-switching fit at all counts as the one-regime case, which is exactly the classic invalid test.

Parameters:

counterpart (_ComparisonMixin) – The other result in the proposed test.

Return type:

str | None

Returns:

A message when the regime counts differ, otherwise None.

Example

>>> import numpy as np
>>> rng = np.random.default_rng(0)
>>> y = rng.standard_normal(300)
>>> two = MarkovSwitchingAR(y, order=1, n_regimes=2).fit(seed=0, n_init=2)
>>> three = MarkovSwitchingAR(y, order=1, n_regimes=3).fit(seed=0, n_init=2)
>>> two._likelihood_ratio_obstacle(three)[:62]
'a chi-squared likelihood-ratio test cannot compare 2 regimes a'
>>> same_k = MarkovSwitchingAR(y, order=1, switching_variance=False)
>>> two._likelihood_ratio_obstacle(same_k.fit(seed=0, n_init=2)) is None
True