3

I have a very small array representing annual values. I'm trying to train a model using auto_arima and then get predictions.

The predictions start off fine, decreasing as we would expect as per the trend in the training data. However, the last 3 values in the prediction actually start to increase. What parameters are causing this increase and do I need to adjust a certain setting to avoid auto_arima fitting this erroneously?

import numpy as np
from pmdarima import auto_arima

train = np.array([0.99, 0.98, 0.97, 0.94, 0.92, 0.90])

stepwise_model = auto_arima(train,
                            seasonal=False
                            )
test_forecast = stepwise_model.predict(n_periods=5)
test_forecast
array([0.88691761, 0.880986  , 0.88232842, 0.89011927, 0.90277567])
matsuo_basho
  • 2,833
  • 8
  • 26
  • 47

1 Answers1

2

You can set the d value to give you a negative trend for your training data. A value of 1 assumes a constant trend (see here.):

train = np.array([0.99, 0.98, 0.97, 0.94, 0.92, 0.90])
stepwise_model = auto_arima(train,
                            seasonal=False,
                            d=1
                            )
test_forecast = stepwise_model.predict(n_periods=5)
test_forecast
array([0.88199983, 0.86399967, 0.8459995 , 0.82799934, 0.80999917])

It looks like auto-arima thinks d=0 is a better fit for your data and so is mean reverting (hence going back up).

What you should do depends on your context and is perhaps better asked on https://stats.stackexchange.com/

Robin Hyndman's book is also a good resource for understanding the underlying ARIMA model: https://otexts.com/fpp3/non-seasonal-arima.html#understanding-arima-models

s_pike
  • 1,710
  • 1
  • 10
  • 22