模型诊断

Python 中的 ARIMA 模型

James Fulton

Climate informatics researcher

模型诊断简介

  • 最终模型有多好?
Python 中的 ARIMA 模型

残差

Python 中的 ARIMA 模型

残差

# Fit model
model = ARIMA(df, order=(p,d,q))
results = model.fit()

# Assign residuals to variable residuals = results.resid
2013-01-23    1.013129
2013-01-24    0.114055
2013-01-25    0.430698
2013-01-26   -1.247046
2013-01-27   -0.499565
       ...         ...
Python 中的 ARIMA 模型

平均绝对误差

预测与真实值相差多远?

mae = np.mean(np.abs(residuals))
Python 中的 ARIMA 模型

诊断图

若拟合良好,残差应为白色高斯噪声

# Create the 4 diagostics plots
results.plot_diagnostics()
plt.show()

Python 中的 ARIMA 模型

残差图

Python 中的 ARIMA 模型

残差图

Python 中的 ARIMA 模型

直方图与估计密度

Python 中的 ARIMA 模型

正态 Q-Q 图

Python 中的 ARIMA 模型

相关图

Python 中的 ARIMA 模型

汇总统计

print(results.summary())
...
===================================================================================
Ljung-Box (Q):                       32.10   Jarque-Bera (JB):                 0.02
Prob(Q):                              0.81   Prob(JB):                         0.99
Heteroskedasticity (H):               1.28   Skew:                            -0.02
Prob(H) (two-sided):                  0.21   Kurtosis:                         2.98
===================================================================================
  • Prob(Q) - 残差不相关性的原假设的 p 值
  • Prob(JB) - 残差正态性的原假设的 p 值
Python 中的 ARIMA 模型

Passons à la pratique !

Python 中的 ARIMA 模型

Preparing Video For Download...