pmdarima icon indicating copy to clipboard operation
pmdarima copied to clipboard

AutoArima 0 mean (no intercept) with constant time series

Open BaklazhenkoNikita opened this issue 1 year ago • 3 comments

Describe the bug

When provided with a completely constant time series (0,0,0) ARMA is being created with no intercept. Hence, for all the constant time series we predict 0. Slight alteration of time series with epsilon on the other hand leads to (0,0,0) ARMA with mean intercept.

To Reproduce

import pandas as pd
from pmdarima import auto_arima
from IPython.display import display

#Testing the Arima predictions with constant time series (returns 0 predictions)
data = pd.Series([1]*20, index=pd.period_range(start='2024-01-01', periods=20, freq='D'))

auto_arima_model = auto_arima(data, error_action='ignore')

n_periods = 5 
forecast = auto_arima_model.predict(n_periods=n_periods)

display(auto_arima_model.summary())
print("Forecast for constant time series:", forecast)

#Testing the Arima predictions with constant time series and one altered value (returns Mean as predictions)
data_non_constant = pd.Series([1]*19 + [1.1], index=pd.period_range(start='2024-01-01', periods=20, freq='D'))

auto_arima_model_non_constant = auto_arima(data_non_constant, error_action='ignore')

n_periods = 5 
forecast = auto_arima_model_non_constant.predict(n_periods=n_periods)

display(auto_arima_model_non_constant.summary())
print("Forecast for almost constant time series:", forecast)

Versions

Linux-5.10.16.3-microsoft-standard-WSL2-x86_64-with-glibc2.31
Python 3.9.11 (main, Mar 17 2022, 06:00:02) 
[GCC 10.2.1 20210110]
pmdarima 1.8.4
NumPy 1.24.4
SciPy 1.11.4
Scikit-Learn 1.2.2
Statsmodels 0.14.1

Expected Behavior

Expect to have ARIMA prediction with a constant (with a mean)

Actual Behavior

Predicts future observations with 0

Additional Context

Error happens in line 443-460, if set with_intercept to True, then we predict with a Mean +- epsilon. ARIMA_0_Constant image

BaklazhenkoNikita avatar Feb 19 '24 12:02 BaklazhenkoNikita

Hi Team, Shall I take up this issue?

shreyash-Pandey-Katni avatar Mar 07 '24 13:03 shreyash-Pandey-Katni

Please feel free @shreyash-Pandey-Katni, and thank you for offering. I've not had the time to look at this

tgsmith61591 avatar Mar 08 '24 02:03 tgsmith61591

Thank you, I will start working on it ASAP.

shreyash-Pandey-Katni avatar Mar 08 '24 15:03 shreyash-Pandey-Katni