始める無料で始める

金利に自己相関はあるでしょうか?

金利の日次変化を見ると、自己相関はゼロに近いです。しかし、データをリサンプリングして年次変化を見ると、自己相関は負になります。これは、短期的な金利変化は相関していない一方で、長期的な金利変化には負の自己相関があることを示唆します。日々の金利の上げ下げは翌日の金利をほとんど示唆しませんが、1年を通した変化は翌年の動きをある程度示してくれます。これは経済的にも自然です。長期では、金利が上がると景気が減速し、結果として金利が下がる傾向があり、その逆もまた起こります。

DataFrame daily_rates には、1962年から2017年までの10年物金利の日次データが含まれています。

この演習はコースの一部です

Pythonで学ぶ時系列解析

コースを見る

演習の手順

  • .diff() メソッドを使って、日次金利の変化を表す新しいDataFrame daily_diff を作成します。
  • .autocorr() メソッドを使い、daily_diff の列 'US10Y' の自己相関を計算します。
  • .resample() メソッドに引数 rule='A' を指定し、続けて .last() を適用して年次頻度に変換します。
  • 年次金利の変化を表す新しいDataFrame yearly_diff を作成し、上と同様に自己相関を計算します。

実践的なインタラクティブ演習

このサンプルコードを完成させて、この演習に挑戦してみましょう。

# Compute the daily change in interest rates 
daily_diff = daily_rates.___

# Compute and print the autocorrelation of daily changes
autocorrelation_daily = daily_diff[___].___
print("The autocorrelation of daily interest rate changes is %4.2f" %(autocorrelation_daily))

# Convert the daily data to annual data
yearly_rates = daily_rates.resample(___).___

# Repeat above for annual data
yearly_diff = yearly_rates.___
autocorrelation_yearly = yearly_diff[___].___
print("The autocorrelation of annual interest rate changes is %4.2f" %(autocorrelation_yearly))
コードを編集して実行