-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH: Multivariate Markov Switching Models #4564
Comments
We had a GSOC project to allow estimating any Markov switching state space model in #2921, and it is reasonably far along, but it has not been merged (partly because it is written in pure Python and so it can be very slow). If you mean something like VAR models with Markov switching, those could be estimated using the Hamilton filter and Kim smoother already in Statsmodels (along very similar lines to the |
Thanks @ChadFulton. I'll take a look and revert back. |
@ChadFulton is there a sample code that you can share? my use case is:- I have a dataframe of N observable features and I want to fit a HMM Gaussian mixture to that. Similar to the example in: I was hoping to get the transition probabilities/ duration of 2 states and state probability predictions Thanks |
@sumit-uk1 I'm not quite sure what model you're looking for:
|
Hi,
I have a NxM matrix of some returns time series (N<M)
Running the code (taken from Markov switching autoregression models — statsmodels)
|
|
| |
Markov switching autoregression models — statsmodels
|
|
|
```python
mod_fedfunds = sm.tsa.MarkovRegression(normalized_corr_df, k_regimes=2)res_fedfunds = mod_fedfunds.fit()
Gives me the error:ValueError Traceback (most recent call last)
<ipython-input-5-200a59bdd86c> in <module>()
----> 1 mod_fedfunds = sm.tsa.MarkovRegression(normalized_corr_df, k_regimes=2)
2 res_fedfunds = mod_fedfunds.fit()
~\Anaconda3\lib\site-packages\statsmodels\tsa\regime_switching\markov_regression.py in __init__(self, endog, k_regimes, trend, exog, order, exog_tvtp, switching_trend, switching_exog, switching_variance, dates, freq, missing)
119 super(MarkovRegression, self).__init__(
120 endog, k_regimes, order=order, exog_tvtp=exog_tvtp, exog=exog,
--> 121 dates=dates, freq=freq, missing=missing)
122
123 # Switching options
~\Anaconda3\lib\site-packages\statsmodels\tsa\regime_switching\markov_switching.py in __init__(self, endog, k_regimes, order, exog_tvtp, exog, dates, freq, missing)
513 # Sanity checks
514 if self.endog.ndim > 1 and self.endog.shape[1] > 1:
--> 515 raise ValueError('Must have univariate endogenous data.')
516 if self.k_regimes < 2:
517 raise ValueError('Markov switching models must have at least two'
ValueError: Must have univariate endogenous data.
```
I was hoping the model will fit a HMM model and give me state transition probabilities and the mean of the 2 states (High vol/ Low vol)
RegardsSumit
|
It sounds like you are looking for a Markov switching VAR model, and we do not support that right now. The only models we have so far are univariate models. |
The
statespace
component already has an excellent module for fitting Markov switching models; however, only univariate models are supported. Is there a way to extend it so as to support multivariate models? Thanks!The text was updated successfully, but these errors were encountered: