ランダムウォーク

Pythonで学ぶ時系列解析

Rob Reider

Adjunct Professor, NYU-Courant Consultant, Quantopian

ランダムウォークとは?

  • 本日の価格 = 前日の価格 + ノイズ

$\large \quad \quad \ P_t \quad \ \ = \quad P_{t-1} \quad \quad \ + \ \ \epsilon_t$

  • シミュレーションデータのプロット

Pythonで学ぶ時系列解析

ランダムウォークとは?

  • 本日の価格 = 前日の価格 + ノイズ

$\large \quad \quad \ P_t \quad \ \ = \quad P_{t-1} \quad \quad \ + \ \ \epsilon_t$

  • 価格変化はホワイトノイズ

$\large \quad \quad P_t - P_{t-1} \quad \ \ = \quad \ \ \epsilon_t$

  • ランダムウォークの予測は不可能
  • 明日の価格の最良予測は今日の価格
Pythonで学ぶ時系列解析

ランダムウォークとは?

  • 本日の価格 = 前日の価格 + ノイズ

$\large \quad \quad \ P_t \quad \ \ = \quad P_{t-1} \quad \quad \ + \ \ \epsilon_t$

  • ドリフト付きランダムウォーク:

$\large \quad \quad \ P_t \quad \ \ = \ \mu \ + \ P_{t-1} \ \ + \quad \epsilon_t$

  • 価格変化は非ゼロ平均のホワイトノイズ:

$\large \quad \quad P_t - P_{t-1} \ \ = \ \mu \ \ + \ \ \epsilon_t$

Pythonで学ぶ時系列解析

ランダムウォークの統計的検定

  • ドリフト付きランダムウォーク

$\large \quad \quad P_t \quad \ \ = \ \mu \ \ + \ \ P_{t-1} \quad \ + \ \ \epsilon_t$

  • ランダムウォークの回帰検定

$\large \quad \quad P_t \quad \ \ = \ \alpha \ \ + \ \ \beta \ P_{t-1} \ \ + \ \ \epsilon_t$

  • 検定:

$\quad \quad \large H_0: \beta=1$(ランダムウォーク)

$\quad \quad \large H_1: \beta<1$(ランダムウォークでない)

Pythonで学ぶ時系列解析

ランダムウォークの統計的検定

  • ランダムウォークの回帰検定

$\large \quad \quad \quad \quad P_t \quad \ \ = \ \alpha \ \ + \ \ \beta \ P_{t-1} \quad \ + \ \ \epsilon_t$

  • 以下と同値

$\large \quad \quad P_t - P_{t-1} \ \ = \ \alpha \ \ + \ \ \beta \ P_{t-1} \ \ + \ \ \epsilon_t$

  • 検定:

$\quad \quad \large H_0: \beta=0$(ランダムウォーク)

$\quad \quad \large H_1: \beta<0$(ランダムウォークでない)

Pythonで学ぶ時系列解析

ランダムウォークの統計的検定

  • ランダムウォークの回帰検定

$\large \quad \quad P_t - P_{t-1} \ \ = \ \alpha \ \ + \ \ \beta \ P_{t-1} \ \ + \ \ \epsilon_t$

  • 検定:

$\large \ \ \ \ H_0: \beta=0$(ランダムウォーク)

$\large \ \ \ \ H_1: \beta<0$(ランダムウォークでない)

  • この検定をディッキー・フラー検定と呼ぶ
  • 右辺にラグ差分を追加したものが拡張ディッキー・フラー検定
Pythonで学ぶ時系列解析

PythonでのADF検定

  • statsmodelsからモジュールをインポート
    from statsmodels.tsa.stattools import adfuller
    
  • 拡張ディッキー・フラー検定を実行
    adfuller(x)
    
Pythonで学ぶ時系列解析

例:S&P500はランダムウォークか?

# Run Augmented Dickey-Fuller Test on SPX data
results = adfuller(df['SPX'])
# Print p-value
print(results[1])
0.782253808587
# Print full results
print(results)
(-0.91720490331127869,
 0.78225380858668414,
 0,
 1257,
 {'1%': -3.4355629707955395,
  '10%': -2.567995644141416,
  '5%': -2.8638420633876671},
 10161.888789598503)
Pythonで学ぶ時系列解析

練習しましょう!

Pythonで学ぶ時系列解析

Preparing Video For Download...