时间序列的 ARMA 预测摘要 ( print arma_mod.summary()
) 显示了一些关于置信区间的数字。是否可以将这些数字用作显示预测值的图中的预测区间?
ax = indexed_df.ix[:].plot(figsize=(12,8))
ax = predict_price.plot(ax=ax, style='rx', label='Dynamic Prediction');
ax.legend();
我猜代码:
from statsmodels.sandbox.regression.predstd import wls_prediction_std
prstd, iv_l, iv_u = wls_prediction_std(results)
在这里找到:Confidence intervals for model prediction
...在这里不适用,因为它是为 OLS 而不是 ARMA 预测制作的。我还检查了 github,但没有找到任何可能与时间序列预测有关的新东西。
(我猜预测需要预测间隔,尤其是在样本外预测时。)
帮助表示赞赏。
最佳答案
我想,对于样本外 ARMA 预测,您可以使用 ARMA.forecast来自 statsmodels.tsa
它返回三个数组:预测值、标准误差和预测的置信区间。
ARMA(1,1) 示例,时间序列 y 和预测提前 1 步:
import statsmodels as sm
arma_res = sm.tsa.ARMA(y, order=(1,1)).fit()
preds, stderr, ci = arma_res.forecast(1)
关于python - ARMA.predict 的预测区间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27801357/