我正在尝试预测标准普尔 500 指数。但是,我得到的预测是平线(没有季节性或任何东西)。尝试使用 python Pyramid Arima 库。数据是标准普尔 500 指数 (SPY),每日“收盘价”。
对 auto_arima 函数有任何建议的更改吗?有没有办法对此进行调整,以便最终预测显示趋势和季节性而不是平坦线?
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()