开始使用免费开始使用

利率是否具有自相关性?

观察利率的日度变动时,自相关性接近 0。不过,如果对数据进行重采样并查看年度变动,自相关性为负。这意味着短期利率变动可能不相关,但长期利率变动呈负自相关。日度的上行或下行几乎不能告诉您明天的利率走向,但一年内的利率变动却能对下一年的利率方向提供一些信息。这个结论在经济上也合理:在较长周期内,利率上升往往会使经济放缓,随后导致利率回落,反之亦然。

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))
编辑并运行代码