共整合模型

Python 中的時間序列分析

Rob Reider

Adjunct Professor, NYU-Courant Consultant, Quantopian

什麼是共整合?

  • 兩個序列 $\large P_t$ 與 $\large Q_t$ 可以是隨機漫步
  • 但線性組合 $\large P_t - c \ Q_t$ 可能不是隨機漫步!
  • 若是如此
    • $\large P_t - c \ Q_t$ 可被預測
    • $\large P_t$ 與 $\large Q_t$ 稱為共整合
Python 中的時間序列分析

比喻:牽繩上的狗

  • $\large P_t = $ 主人
  • $\large Q_t = $ 狗
  • 兩個序列都像隨機漫步
  • 它們的差(距離)看起來均值回復
    • 狗落後太多時,會被往前拉
    • 狗超前太多時,會被拉回來
Python 中的時間序列分析

範例:煉油與天然氣

  • 煉油與天然氣看起來都像隨機漫步…

Python 中的時間序列分析

範例:煉油與天然氣

  • 但價差(差值)呈現均值回復

Python 中的時間序列分析

哪些序列會共整合?

  • 經濟替代品
    • 煉油與天然氣
    • 鉑與鈀
    • 玉米與小麥
    • 玉米與糖
    • Bitcoin 與 Ethereum?
  • 那競爭對手呢?
    • 可口可樂與百事可樂?
    • Apple 與 Blackberry?不!牽繩斷了,狗跑走了
Python 中的時間序列分析

檢定共整合的兩個步驟

  • 以 $\large Q_t$ 迴歸 $\large P_t$,取得斜率 $\large c$
  • 對 $\large P_t - c \ Q_t$ 做 Augmented Dickey-Fuller 檢定以測試是否為隨機漫步
  • 或使用 statsmodels 的 coint 函式,一次完成兩步
from statsmodels.tsa.stattools import coint
coint(P,Q)
Python 中的時間序列分析

一起來練習吧!

Python 中的時間序列分析

Preparing Video For Download...