Skip to content

DESIGN: Roadmap for time series #3115

Open

Description

@ChadFulton

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:
    1. Handling dates for wrapping output is not general. It relies on internal state, and was written for predict and forecast and 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).
    2. 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.
  • sm.tsa.AR - is this still worth keeping around? It doesn't match the current Statsmodels modeling paradigm (i.e. the specification is in the fit method rather than the constructor) and there are two other classes that can fit AR models (sm.tsa.ARIMA and sm.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 of tsa fit together. I'm not very familiar with it, but I think a lot of its functionality is duplicated by sm.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 maxlag and ic arguments to fit in sm.tsa.AR, sm.tsa.VAR, and sm.tsa.SVAR but is not explicitly supported by sm.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.ARIMA in 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 with sm.tsa.AR).
    1. Eliminate ar_model.py
    2. Extract the conditional-MLE / CSS components (and anything else not duplicated elsewhere) of sm.tsa.ARMA and sm.tsa.ARIMA and put them in a new semi-internal class (e.g. sm.tsa.LeastSquaresARIMA).
    3. Create new thin wrapper classes sm.tsa.AR, sm.tsa.ARMA, sm.tsa.ARIMA that delegate to sm.tsa.LeastSquaresARIMA (called if method == 'css') and sm.tsa.SARIMAX (called if method == 'mle').
  • Deprecate sm.tsa.VAR in v0.9 and replace it with a new version in v0.10, maintaining as much backwards compatibility as possible.
    1. Rename sm.tsa.VAR into new semi-internal class (e.g. sm.tsa.LeastSquaresVAR).
    2. Create new thin wrapper class sm.tsa.VAR that by default delegates to sm.tsa.LeastSquaresVAR. Since sm.tsa.VARMAX is currently pretty far behind sm.tsa.VAR in terms of post-estimation (IRF, FEVD, etc.), I think it should raise a NotImplementedError if method == 'mle' until it catches up.
  • 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. eliminating maxlags order selection in fit).
  • 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 throw NotImplementedError rather 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

  1. josef-pkt commented on Jul 16, 2016

    @josef-pkt
    Member

    @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,

    • date handling is a major source of current problems, and anything that improves and updates the generic TimeSeriesModel framework would be very helpful overall.
    • independent of the implementation of fit algorithms, 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.
    • I also think that we need the specification search outside of the models, and need to improve it.

    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:

    • AR: theoretically that is much easier to estimate because OLS essentially already works. My main worry about merging it into or delegating to ARIMA/SARIMAX is in performance. However, AR has several problems in the current implementation.
    • VAR/VARIMAX/SVAR/VECM/SVECM/LargeVAR:
      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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions