Search code examples
pythontime-seriesarima

auto_arima gives same result for different periods?


I have sample dataset, i want to predict following result for 2 periods. But prediction function gives me same results.

This is my dataset (data['t1']);

0     83.846
1     73.350
2     66.499
3     63.576
4     66.545
5     57.264
6     63.009
7     59.608
8     62.775
9     58.451
10    80.893
11    58.734
12    77.830
13    73.374
14    61.650
15    52.548
16    31.683
17    57.599
18    70.814
19    65.354
20    60.033
21    50.162
22    60.764
23    53.799
24    67.266
25    65.520
26    71.248
27    60.457
28    52.424
29    55.622
30    78.149
31    72.111 

Code ;

from statsmodels.tsa.arima_model import ARIMA
import pmdarima as pm
model = pm.auto_arima(data['t1'], start_p=1, start_q=1,
                      test='adf',       # use adftest to find optimal 'd'
                      max_p=5, max_q=5, # maximum p and q
                      m=1,              # frequency of series
                      d=None,           # let model determine 'd'
                      seasonal=True,  
                      start_P=0, 
                      D=0, 
                      trace=True,
                      error_action='ignore',  
                      suppress_warnings=True, 
                      stepwise=True)

print(model.summary())

Prediction;

predict, conf_int  = model.predict(2,return_conf_int=True,alpha=0.05)
predict

Result ;

array([71.88338364, 71.88338364])

How can i solve this problem? Does something wrong on my auto_arima model?

fit_summary;

Best model:  ARIMA(0,1,1)(0,0,0)[0]          
Total fit time: 0.579 seconds
                               SARIMAX Results                                
==============================================================================
Dep. Variable:                      y   No. Observations:                   34
Model:               SARIMAX(0, 1, 1)   Log Likelihood                -126.062
Date:                Mon, 15 Nov 2021   AIC                            256.124
Time:                        16:25:30   BIC                            259.117
Sample:                             0   HQIC                           257.131
                                 - 34                                         
Covariance Type:                  opg                                         
==============================================================================
                 coef    std err          z      P>|z|      [0.025      0.975]
------------------------------------------------------------------------------
ma.L1         -0.5351      0.156     -3.438      0.001      -0.840      -0.230
sigma2       120.5502     31.181      3.866      0.000      59.436     181.664
===================================================================================
Ljung-Box (L1) (Q):                   0.62   Jarque-Bera (JB):                 0.01
Prob(Q):                              0.43   Prob(JB):                         1.00
Heteroskedasticity (H):               1.11   Skew:                            -0.02
Prob(H) (two-sided):                  0.87   Kurtosis:                         2.94
===================================================================================

Solution

  • Your ARIMA model only uses the last component, so it is an MA model. Such an MA model can only predict q steps into the future, so in your case only one step. If you want to predict more than one step, you either need to increase q or switch to an AR model.