0

I am new in modelling time series data using arima

I have a timeseries of similarity score calculated using Ademic Adar index. However when I use ARIMA it gives constant prediction to some data, what should I do?

This is what I have

Results=np.dstack([aa_matrix,aa_matrix_2,aa_matrix_3,aa_matrix_4,aa_matrix_5,aa_matrix_6])
Results=Results.reshape(-1)
size = int(len(Results) * 0.988597)
train, test = Results[0:size], Results[size:len(Results)]

from statsmodels.tsa.arima.model import ARIMA
model = ARIMA(train,  order=(2,1,1))
model_fit = model.fit()
output = model_fit.forecast(steps=len(test))

Example output

[0.0026541988296397982, 0.002654198829639803, 0.002654198829639807, 0.0026541988296398104, 0.0026541988296398134, 0.002654198829639816, 0.002654198829639818, 0.00265419882963982, 0.0026541988296398212, 0.0026541988296398225, 0.0026541988296398234, 0.0026541988296398243, 0.002654198829639825, 0.0026541988296398256, 0.002654198829639826, 0.0026541988296398264, 0.002654198829639827, 0.0026541988296398273, 0.0026541988296398277, 0.0026541988296398277, 0.0026541988296398277, 0.0026541988296398277, 0.0026541988296398277, 0.0026541988296398277, 0.0026541988296398277, 0.0026541988296398277, 0.0026541988296398277, 0.0026541988296398277, 0.0026541988296398277, 0.0026541988296398277, 0.0026541988296398277, 0.0026541988296398277, 0.0026541988296398277, 0.0026541988296398277, 0.0026541988296398277, 0.0026541988296398277, 0.0026541988296398277, 0.0026541988296398277, 0.0026541988296398277, 0.0026541988296398277, 0.0026541988296398277, 0.0026541988296398277, 0.0026541988296398277, 0.0026541988296398277, 0.0026541988296398277, 0.0026541988296398277, 0.0026541988296398277, 0.0026541988296398277, 0.0026541988296398277, 0.0026541988296398277, 0.0026541988296398277, 0.0026541988296398277, 0.0026541988296398277]

I have also read this Statsmodels ARIMA: Constant Value for Each Forecast Also I saw one comment says, try to add drift, but I don't know how to do it

Any help will be much appreciated Thank you in advance

TinaTz
  • 311
  • 3
  • 16
  • Can you write the import statement of the `ARIMA` you are using? – Mustafa Aydın Mar 17 '21 at 11:57
  • @MustafaAydın I add it already – TinaTz Mar 17 '21 at 12:02
  • Okay, you can see [this](https://stackoverflow.com/questions/66651360/arima-forecast-gives-different-results-with-new-python-statsmodels) similar question and answer therein for a detailed reason; but in short, when differencing is involved (i.e. `d=1` for your case, middle 1 in the order), the model doesn't include a constant. Your predictions are not constant by the way (if you look close enough!); but to add this constant (which will be reflected as "drift" due to differencing, you might get "better" results. So, please try `model = ARIMA(train, order=(2,1,1), trend="t")`. – Mustafa Aydın Mar 17 '21 at 12:07
  • I tried, but its not giving good results for prediction @MustafaAydın – TinaTz Mar 17 '21 at 13:39
  • What do you mean by not good? – Mustafa Aydın Mar 17 '21 at 13:50
  • [1.1173112797712648, 1.1124011518602668, 1.1082592151044333, 1.1047823491149, 1.1018639446198435, 1.0994141052701127, 1.0973573970376913, 1.095630529785795, 1.0941804024458042, 1.092962462685078, 1.0919393306468554, 1.091079644254034, 1.090357090407383, 1.089749592151066, 1.089238626696311, 1.088808653236385, 1.0864392473716762, 1.0864269702887739, 1.086415401406161,] Here I see one is added to all predictions, Is it correct? – TinaTz Mar 17 '21 at 15:17
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/230035/discussion-between-christina-muro-and-mustafa-aydin). – TinaTz Mar 17 '21 at 15:17

0 Answers0