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: Markov-switching regression and autoregression models (non-state space) #2980
Conversation
partially in response to #2921 (comment) @ChadFulton @ValeryTyumen Would it help to merge this into master? Given that this has good test coverage and looks pretty complete, we could merge it, possibly with a Warning that this is currently under refactoring during GSOC. On the other hand #2921 has another unmerged PR in between. General policy could be to allow merges of master into a feature branch and remove it again during an interactive rebase before the final review and merge. The main problem for reviewing is that the merged code shows up as part of the PR, AFAIK and makes the change set less useful. |
Lots of improvements and bug fixes, along with example notebooks that can be found here: With reference to the question about merging, this can probably be merged. The only features missing right now are |
@ValeryTyumen Sorry about this, but due to a name change I suggested for you, I renamed the |
Rebased on master. |
Changes Unknown when pulling 95714ca on ChadFulton:markov-tsa into * on statsmodels:master*. |
Rebased on master. Probably not ready to be merged in as "stable", although the only thing it is actually missing right now is out-of-sample forecasting. It could be included in 0.8 if there was a way to indicate that it was still new / unstable. |
If it's safe enough, then it would be good to get it in. We can add an "experimental" or similar status qualifier to the docstring. |
I will plan to merge it this weekend then, but I will improve the test coverage first. |
# Inherited parameters | ||
param_names = np.array( | ||
markov_regression.MarkovRegression.param_names.fget(self), | ||
dtype=object) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why an object array and not a list of strings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's because below I use indexing with lists of integers (the self.parameters[i, 'autoregressive']
)
This looks fine based on a very very brief skimming. I leave the details to you and @ValeryTyumen You refer to EViews in some of the unit tests, but as far as I could see, there is no origin or source for the reference numbers mentioned in other tests. Can you add some comment, so we can find it again later? |
This errors on appveyor but not on TravisCI several files in tests/results cannot be found, e.g. (BTW: current master has the failing imputation test disabled, and PRs should run green after rebase.) |
Changes Unknown when pulling 404f065 on ChadFulton:markov-tsa into * on statsmodels:master*. |
filter, Kim smoother.
Looks green to me, but I can't figure out how to interpret the coverage details; it doesn't seem like the coverage report has anything to do with the changes in this PR. |
@ChadFulton add a module I think TravisCI is not running any tests here. I don't know why appveyor and travis behave differently with respect to this. |
Well that would make sense. Thanks for catching that! |
I don't see why now travis complains about missing results/xxx.csv files. Those should be automatically included as datafiles in the source distribution (all csv, txt and dta files in results directories) |
@ChadFulton you could try locally I just realized that the travis error message has a |
@classmethod | ||
def setup_class(cls): | ||
path = (current_path + os.sep + 'results' + os.sep + | ||
'results_predict_rgnp.csv') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try using os.path.join instead of explicit composition, which is cleaner anyway
Since appveyor doesn't have problems, it's os (Linux) specific os.path issue, not a missing file in the |
Thanks for debugging this, I haven't run into problems like this before. |
I don't know why we need the merging given it's all green Thanks Chad |
predict or forecast are not included in the package? I couldn't deploy neither of them after model fitting. |
Only in-sample predictions are available right now. Out-of-sample forecasting has not yet been added, although pull requests adding that functionality would be greatly appreciated. |
The one-step forward forecast of time T+1 value is not a problem, but how to forecast the hidden status of the new observation? or any suggestions on deriving hidden status from time T+1 to T' of the new observations y_T+1,t_T+2,...y_T' after building Markov autoregression model on observations y_1,y_2,... y_T? |
I described and implemented this algorithm in my pull request - #2921 (comment). |
Thanks. I have looked at the description, if I understand them correctly, the forecast algo is for unknown regimes and unknown observations, what if the new observations are known, can we still derive the hidden regimes? |
Sounds like a usual Kim filter routine to me. |
Ok, I will take a close look at Kim Filter later, still new to this. |
Am also interested in out-of-sample forecasting, both conditional on regime/exogenous and with unknown regime. |
This is a cleaned up / rewritten version of the Markov switching models from my 2013 GSOC. Allows:
My thought is to finish developing this alongside @ValeryTyumen who is doing the state space Markov switching models so that we can maintain a constant interface, etc.