Skip to content
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

BUG: SARIMAX Extend with constant exog doesn't work #8991

Open
UgurKap opened this issue Sep 2, 2023 · 1 comment
Open

BUG: SARIMAX Extend with constant exog doesn't work #8991

UgurKap opened this issue Sep 2, 2023 · 1 comment

Comments

@UgurKap
Copy link

UgurKap commented Sep 2, 2023

Describe the bug

Similar to this issue: #7019

It seems the above bug is solved, but when you try to extend a SARIMAX model with constant exog values, it throws an error

Code Sample, a copy-pastable example if possible

from statsmodels.tsa.arima.model import ARIMA
import numpy as np

# A normal training demo

# Old data
old_data = np.random.rand(12*10, 1)
old_exo = np.random.rand(10, 1)
old_exo = np.repeat(old_exo, 12).reshape(-1, 1)

# Model fit with the available data
m = ARIMA(old_data, exog=old_exo)
res = m.fit()

# Some new data arrives
new_data = np.random.rand(12, 1)
new_exo = np.repeat(np.random.rand(1, 1), 12).reshape(-1, 1)

# The following line should not fail, but it does
res.extend(new_data, exog=new_exo)

We get ValueError: A constant trend was included in the model specification, but the exog data already contains a column of constants.

Expected Output

It should just extend the model without checking if exog is constant or not, as exog changes every "h" periods. When I try to extend the model after doing "h" periods where exog doesn't change, we get the error above.

Output of import statsmodels.api as sm; sm.show_versions()

INSTALLED VERSIONS

Python: 3.10.11.final.0
OS: Linux 5.14.0-70.30.1.el9_0.x86_64 #1 SMP PREEMPT Thu Nov 3 20:29:04 UTC 2022 x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8

statsmodels

Installed: 0.14.0 (/mnt/lustre/ludwig/lqb955/conda_envs/air_forecast/lib/python3.10/site-packages/statsmodels)

Required Dependencies

cython: Not installed
numpy: 1.23.5 (/mnt/lustre/ludwig/lqb955/conda_envs/air_forecast/lib/python3.10/site-packages/numpy)
scipy: 1.11.1 (/mnt/lustre/ludwig/lqb955/conda_envs/air_forecast/lib/python3.10/site-packages/scipy)
pandas: 2.0.3 (/mnt/lustre/ludwig/lqb955/conda_envs/air_forecast/lib/python3.10/site-packages/pandas)
dateutil: 2.8.2 (/mnt/lustre/ludwig/lqb955/conda_envs/air_forecast/lib/python3.10/site-packages/dateutil)
patsy: 0.5.3 (/mnt/lustre/ludwig/lqb955/conda_envs/air_forecast/lib/python3.10/site-packages/patsy)

Optional Dependencies

matplotlib: 3.7.1 (/mnt/lustre/ludwig/lqb955/conda_envs/air_forecast/lib/python3.10/site-packages/matplotlib)
backend: module://matplotlib_inline.backend_inline
cvxopt: Not installed
joblib: 1.3.1 (/mnt/lustre/ludwig/lqb955/conda_envs/air_forecast/lib/python3.10/site-packages/joblib)

Developer Tools

IPython: 8.14.0 (/mnt/lustre/ludwig/lqb955/conda_envs/air_forecast/lib/python3.10/site-packages/IPython)
jinja2: 3.1.2 (/mnt/lustre/ludwig/lqb955/conda_envs/air_forecast/lib/python3.10/site-packages/jinja2)
sphinx: Not installed
pygments: 2.15.1 (/mnt/lustre/ludwig/lqb955/conda_envs/air_forecast/lib/python3.10/site-packages/pygments)
pytest: Not installed
virtualenv: Not installed

@ChadFulton
Copy link
Member

Thanks very much for posting this, definitely a bug with ARIMA.extend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants