我想创建一个Arima模型,以便根据以下数据集来预测未来的温度:https://data.giss.nasa.gov/gistemp/tabledata_v3/GLB.Ts+dSST.txt
这是数据的分解: Time Series Decomposition
对于Arima参数,我尝试了以下方法:
import warnings
p = d = q = range(0, 2)
pdq = list(itertools.product(p, d, q))
seasonal_pdq = [(x[0], x[1], x[2], 12) for x in list(itertools.product(p, d,
q))]
warnings.filterwarnings("ignore")
for param in pdq:
for param_seasonal in seasonal_pdq:
try:
mod = sm.tsa.statespace.SARIMAX(df,
order=param,
seasonal_order=param_seasonal,
enforce_stationarity=True,
enforce_invertibility=False)
results = mod.fit()
print('ARIMA{}x{}12 - AIC:{}'.format(param, param_seasonal, results.aic))
except:
continue
具有以下输出: AIC values
mod = sm.tsa.statespace.SARIMAX(df,
order=(1, 1, 1),
seasonal_order=(1, 0 , 1, 12),
enforce_stationarity=True,
enforce_invertibility=False)
results = mod.fit()
print(results.summary().tables[1])
这是时间序列预测: Time Series Forecast
当我尝试预测未来价值时:
pred_uc = results.get_forecast(steps=100)
pred_ci = pred_uc.conf_int()
ax = df['2000-01-31':].plot(label='observed', figsize=(14, 7))
pred_uc.predicted_mean.plot(ax=ax, label='Forecast')
ax.fill_between(pred_ci.index,
pred_ci.iloc[:, 0],
pred_ci.iloc[:, 1], color='k', alpha=.25)
plt.legend()
plt.show()
我有以下输出: Forecast Output
我想知道是否有办法改善预测范围。