ACF 與 PACF 入門

Python 中的 ARIMA 模型

James Fulton

Climate informatics researcher

動機

Python 中的 ARIMA 模型

ACF 與 PACF

  • ACF-自相關函數
  • PACF-偏自相關函數
Python 中的 ARIMA 模型

什麼是 ACF

  • 滯後 1 的自相關 $\rightarrow$ $corr(y_t, y_{t-1})$
  • 滯後 2 的自相關 $\rightarrow$ $corr(y_t, y_{t-2})$
  • 滯後 n 的自相關 $\rightarrow$ $corr(y_t, y_{t-n})$
Python 中的 ARIMA 模型

什麼是 ACF

Python 中的 ARIMA 模型

什麼是 PACF

Python 中的 ARIMA 模型

用 ACF 與 PACF 選模型階數

  • AR(2) 模型 $\rightarrow$

Python 中的 ARIMA 模型

用 ACF 與 PACF 選模型階數

  • MA(2) 模型 $\rightarrow$

Python 中的 ARIMA 模型

用 ACF 與 PACF 選模型階數

Python 中的 ARIMA 模型

用 ACF 與 PACF 選模型階數

Python 中的 ARIMA 模型

在 Python 中實作

from statsmodels.graphics.tsaplots import plot_acf, plot_pacf
# Create figure
fig, (ax1, ax2) = plt.subplots(2,1, figsize=(8,8))

# Make ACF plot plot_acf(df, lags=10, zero=False, ax=ax1)
# Make PACF plot plot_pacf(df, lags=10, zero=False, ax=ax2) plt.show()
Python 中的 ARIMA 模型

在 Python 中實作

Python 中的 ARIMA 模型

過度/不足差分與 ACF、PACF

Python 中的 ARIMA 模型

過度/不足差分與 ACF、PACF

Python 中的 ARIMA 模型

一起來練習吧!

Python 中的 ARIMA 模型

Preparing Video For Download...