Repository navigation
Open
Description
Starting an issue to discuss the longer-term roadmap for tsa with some of my thoughts / questions. The major theme I have in mind is making tsa more consistent in terms of inputs, outputs, and methods. Obviously we haven't even released with state space models, so I am surely "getting ahead of myself".
Some specific thoughts:
TimeSeriesModel: this was written a long time ago (e.g. includes the comment#NOTE: Can drop this once we move to pandas >= 0.8.x), and probably includes a lot of code that is no longer necessary with modern Pandas. Cleaning it up shouldn't be too much work, but redoing the date wrapping behavior might take some work, see below.- Results wrapping: there are two concerns here that I've run into specifically:
- Handling dates for wrapping output is not general. It relies on internal state, and was written for
predictandforecastand so is tied directly into those things. One issue is that when we have output arrays that could be associated with dates, they can't be wrapped right now because we can't set the internal state (without doing yet another set of property wrappers to call the right functions first). - It doesn't really play well with multivariate models. The multivariate support that exists was bolted on to work specifically with the VAR class, and so is pretty tough to work with.
- Handling dates for wrapping output is not general. It relies on internal state, and was written for
sm.tsa.AR- is this still worth keeping around? It doesn't match the current Statsmodels modeling paradigm (i.e. the specification is in thefitmethod rather than the constructor) and there are two other classes that can fit AR models (sm.tsa.ARIMAandsm.tsa.SARIMAX).sm.tsa.ARIMA- is this still worth keeping around? I'm guessing it is, or at least parts of it are; I'm just trying to figure out how all the pieces oftsafit together. I'm not very familiar with it, but I think a lot of its functionality is duplicated bysm.tsa.SARIMAX(except for CSS fitting?). My main concern is that I don't know if anyone is maintaining these models.- Model selection: currently, this is handled by
maxlagandicarguments tofitinsm.tsa.AR,sm.tsa.VAR, andsm.tsa.SVARbut is not explicitly supported bysm.tsa.ARMA,sm.tsa.ARIMA, or any of the state space models. Since the current paradigm is that order should be specified in__init__, I think this should be moved out of the models themselves completely, and model selection should be handled with some kind of external helper function / class.
Naive proposal:
Here is an (ambitious, naive) proposal which is probably not the right way to go about things in many ways, but might be a start:
- Deprecate
sm.tsa.AR,sm.tsa.ARMA,sm.tsa.ARIMAin v0.9 and replace them with new versions in v0.10, maintaining as much backwards compatibility as possible (but will definitely have to break things especially withsm.tsa.AR).- Eliminate
ar_model.py - Extract the conditional-MLE / CSS components (and anything else not duplicated elsewhere) of
sm.tsa.ARMAandsm.tsa.ARIMAand put them in a new semi-internal class (e.g.sm.tsa.LeastSquaresARIMA). - Create new thin wrapper classes
sm.tsa.AR,sm.tsa.ARMA,sm.tsa.ARIMAthat delegate tosm.tsa.LeastSquaresARIMA(called ifmethod == 'css') andsm.tsa.SARIMAX(called ifmethod == 'mle').
- Eliminate
- Deprecate
sm.tsa.VARin v0.9 and replace it with a new version in v0.10, maintaining as much backwards compatibility as possible.- Rename
sm.tsa.VARinto new semi-internal class (e.g.sm.tsa.LeastSquaresVAR). - Create new thin wrapper class
sm.tsa.VARthat by default delegates tosm.tsa.LeastSquaresVAR. Sincesm.tsa.VARMAXis currently pretty far behindsm.tsa.VARin terms of post-estimation (IRF, FEVD, etc.), I think it should raise a NotImplementedError ifmethod == 'mle'until it catches up.
- Rename
- I don't know what to do with
sm.tsa.SVAR, so I guess we can just leave it alone, except for making some changes to make the interface consistent (e.g. eliminatingmaxlagsorder selection infit). - Enforce that all models are consistent in terms of:
- Parameter names (notation for lags, exogenous coefficients, etc.)
- A consistent set of methods in the model classes (e.g.
fit,predict,forecast,simulate,impulse_responses) with consistent arguments and consistent output. Obviously allow for some methods to not be implemented, but require that they throwNotImplementedErrorrather than not having the method at all. - A consistent set of attributes and methods in the results classes
- A consistent format for summary output.
- Construct a new model selection class that accepts a list of specifications and selects the best model on the basis of some IC. Potentially tie in with parallel estimation, etc.
Activity
josef-pkt commentedon Jul 16, 2016
@ChadFulton Thanks Chad, that's very helpful to start with improving the consistency and structure of tsa.
First, inertia, backwards compatibility and advantages of different models/implementations might not move this very fast. i.e. build up and advertise new models before deleting old models. That's mainly about timing not about the direction to go.
I agree to a large extent with this based on my semi-outsider view.
about some specific issues,
fitalgorithms, a larger use of consistent, up-to-date helper methods and functions will be necessary, and will enable to share code with a consistent implementation and api.Are there still performance differences between ARMA and an ARMA model through SARIMAX?
ARMA/ARIMA versus SARIMAX would be the closest match for removing duplicate functionality.
where I'm doubtful:
I think that essentially we don't know enough to merge those. At least I don't have an overview on how we could fit them together.
VAR looks overall pretty good, but has quite a lot of details that are "not very clean". The current implementation is essentially OLS, or SUR with identical regressors, which is the computationally efficient way to implement it. Most parts of the post estimation features should be reusable by all related model, or should be made to be reusable.
VECM in the basic form has 3 estimation methods but all are closed form linear algebra.
VARIMAX can provide the most general version but with statespace representation and nonlinear optimization it will be slower than the pure linear algebra solutions.
For LargeVAR and VAR with constraints on lag coefficients, a computationally and memory efficient solution will be similar to
sysreg, i.e. general sparse SUR estimation.