Skip to content

DESIGN: Speed up innovations algorithm / filter with Cython or Numba? #5326

Closed

Description

@ChadFulton

The innovation algorithm added by @bashtage in #5042 can give us a way to compute the exact log-likelihood function of an ARMA process (see https://github.com/statsmodels/statsmodels/pull/5325/files#diff-8d4eb599f6121222f9a183e3a7205f9bR794).

I'm not sure, but it seems as though this approach could be a lot faster for ARMA models since it avoids a lot of the unnecessary operations implicit in the matrix-based state space models approach. This is especially true for SARIMA models with long seasonal effects, which we have gotten several questions about.

I know @bashtage mentioned that his existing functions can be trivially sped up by numba, which I think we're planning to make an optional dependency?

I can also easily write a Cython version, but I don't know if we want to head more into the numba direction, since the code is easier for most people to read / edit / debug?

Activity

  1. bashtage commented on Oct 18, 2018

    @bashtage
    Member

    I suppose one has to do the experiment to see if it really is faster. It will probably have other warts when processes highly persistent or anti-persistent.

  2. josef-pkt commented on Oct 20, 2018

    @josef-pkt
    Member

    In general I think cython is more stable then numba, i.e. once the bugs are fixed, it's just C and we don't need to worry what the current version of JIT does.
    numba is more useful for developers that don't know cython well enough, and maybe in cases where we need more flexibility.

    I think with both of you, Chad and Kevin, using cython in tsa, there is no problem putting additional filters into cython.

    When I get around to Poisson time series processes, then I'd rather use numba than cython because it looks less painful for me.

  3. bashtage commented on May 13, 2019

    @bashtage
    Member

    @ChadFulton Can this be closed now?

  4. ChadFulton commented on May 13, 2019

    @ChadFulton
    MemberAuthor

    I guess so - where we are right now, we have a Cythonized version of the innovations algorithm that works only for specified ARMA processes, in e.g. innovations.arma_innovations. It can not be used with an estimated autocovariance function like stattools.innovations_algo can, because it takes advantage of the specific form of the autocovariance matrix for stationary ARMA processes.

    I think you mentioned in your original PR for innovations_algo and innovations_filter that Numba yielded significant performance improvements, and that still seems to me like a worthwhile improvement, but could be a different issue / PR.

  5. bashtage commented on May 13, 2019

    @bashtage
    Member

    Sounds like this stays open.

  6. jbrockmendel commented on May 13, 2019

    @jbrockmendel
    Contributor

    PERF tag?

  7. added 2 commits that reference this issue on Jul 15, 2019
    7f6fc51
    9e3586e
  8. added this to the 0.11 milestone on Dec 18, 2019
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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions