Skip to content

BUG: SARIMAX does not accept NumPy integer periodicty #5570

@hylkedonker

Description

@hylkedonker

Passing a NumPy integer (instead of a Python integer) to the periodicty in the seasonal_order argument of SARIMAX raises the exception:

TypeError: object of type 'numpy.int64' has no len()

The following minimal code snippet reproduces the problem:

from numpy import *
from statsmodels.tsa.statespace.sarimax import SARIMAX

t = linspace(0, 8.0*pi, num=40 + 1)
y = sin(t) + random.normal(scale=0.5, size=len(t))
model = SARIMAX(
    y,
    seasonal_order=(0, 1, 0, int64(10))).fit()

The problem is in fact related to isinstance(int64(), int) being False, see also numpy/numpy#2951.
I am ussing statsmodels version 0.9.0, but looking at the master branch https://github.com/statsmodels/statsmodels/blob/master/statsmodels/tsa/statespace/tools.py#L181 I expect that this problem is not limited to my version only.
As a quick fix in my own code I do:

seasonal_order = tuple(int(i) for i in seasonal_order)

but it would be desirable if SARIMAX also works with NumPy integers.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions