Reputation: 323
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()
# 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()
Upvotes: 0
Views: 4533
Reputation: 1238
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.
Upvotes: 1