0

I am trying to forecast the S&P 500. But, I am getting a flatline for the forecast (no seasonality or anything). Attempting to use the python Pyramid Arima library. The data is the S&P 500 (SPY), daily 'close.'

Any suggested changes to the auto_arima function? Is there a way to adjust this so that the final forecast shows with trends and seasonality instead of a flatline?

import pmdarima as pm

smodel = pm.auto_arima(data, start_p=0, start_q=0,
                         test='adf',
                         max_p=4, max_q=4, m=7,
                         start_P=0, seasonal=True,
                         d=None, D=1, trace=True,
                         error_action='ignore',  
                         suppress_warnings=True, 
                         stepwise=True)

smodel.summary()

enter image description here

# Forecast
n_periods = 52
fitted, confint = smodel.predict(n_periods=n_periods, return_conf_int=True)
index_of_fc = pd.date_range(data.index[-1], periods = n_periods, freq='MS')

# make series for plotting purpose
fitted_series = pd.Series(fitted, index=index_of_fc)
lower_series = pd.Series(confint[:, 0], index=index_of_fc)
upper_series = pd.Series(confint[:, 1], index=index_of_fc)

# Plot
plt.plot(data)
plt.plot(fitted_series, color='darkgreen')
plt.fill_between(lower_series.index, 
                 lower_series, 
                 upper_series, 
                 color='k', alpha=.15)

plt.title("SARIMA - Final Forecast of SPY")
plt.show()

enter image description here

billv1179
  • 323
  • 5
  • 15

1 Answers1

1

This thing happen when your historical data doesn't have strong seasonality and the forecasting model finds difficult to predict the future data points there fore it simply take average of your previous values and predict as future. There fore you are getting straight line.

Zeeshan
  • 1,208
  • 1
  • 14
  • 26
  • Thank you! As an experiment on this, I've attempted to feed in less data points from the past, where there is a bit more trend. After doing this, it did forecast beyond a flat line average as it has been doing. – billv1179 Jan 10 '20 at 11:46