无法使用 SARIMA 绘制预测值

Can not plot predictedvalues with SARIMA

我正在用 statsmodels.tsa.statespace.sarimax 构建 SARIMA 时间序列,因为 pmdarima 没有安装。我的数据每季度有 44 个观察 10 年。我的目标是预测未来 1 或 2 年。任何人都可以知道我需要什么来预测。我不精通 Python,但我认为我的季度数据与期望的预测之间存在某种误解。我从 towardsdatascience、这里的文章和 youtube 编译算法。 在使用最小 AIC 评估 P、D、Q、m 参数并拟合模型后,这就是结果 - 无法绘制预测步骤 我制作了 2 列 - 日期和 GVA - 我正在寻找的总附加值 Data set is here

如果有人能帮忙..

Google collab notebook is here Dataset I have collected is here

在准备数据的时候(设置索引权,平稳化等),我通常会做如下操作:

model2 = sm.tsa.statespace.SARIMAX(df['x'], order=(0, 1, 3), seasonal_order=(0, 1, 1, 4))
res2 = model2.fit()
pred_uc2 = res2.get_forecast(steps=12) # note here the usage of steps ahead and get_forecast
pred_ci2 = pred_uc2.conf_int()
ax = df['x'].plot(label = OB, figsize=(14, 8)) # test data
pred_uc2.predicted_mean.plot(ax=ax, label=FC) $ prediction
ax.fill_between(pred_ci2.index, # confidence intervals
                pred_ci2.iloc[:, 0],
                pred_ci2.iloc[:, 1], color='k', alpha=.25)
ax.set_xlabel('Date')
ax.set_ylabel('Price')
plt.legend()
plt.show()