Robert J. Hodrick and Tuomas Tomunen
3/26/2019
In this notebook, we describe the sources and the construction of interest rate and exchange rate data used in "Taking the Cochrane-Piazzesi Term Structure Model Out of Sample: More Data, Additional Currencies, and FX Implications". Then, as a diagnostics test, we graphically compare our interest rate data to Wright (2011) data.
US
UK
Germany
Switzerland
Canada
Japan
Australia
Sweden
Norway
New Zealand
Exchange rates
Wright data
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
COUNTRY_CURRENCY_MAP = {'US': 'USD',
'UK': 'GBP',
'Germany': 'EUR',
'Switzerland': 'CHF',
'Canada': 'CAD',
'Japan': 'JPY',
'Australia': 'AUD',
'Sweden': 'SEK',
'Norway': 'NOK',
'New Zealand': 'NZD'}
# Wright (2011) data
wright_data = {}
for i in COUNTRY_CURRENCY_MAP.keys():
wright_df = pd.read_excel('raw_data/ZCdata.xls', sheet_name=i, header=1).reset_index()
wright_df['date'] = pd.to_datetime(wright_df['level_0']*10000+wright_df['level_1']*100+1, format='%Y%m%d') + pd.offsets.MonthEnd(0)
wright_df = wright_df.set_index('date')
wright_data[i] = wright_df[[12, 24, 36, 48, 60]]
# Own data
own_data = {}
for i, c in COUNTRY_CURRENCY_MAP.items():
own_df = pd.read_csv('{}.csv'.format(c), parse_dates=['date'])
own_df.columns = ['date', 12, 24, 36, 48, 60]
own_data[i] = own_df.set_index('date')
fig, ax = plt.subplots(nrows=10, ncols=5, figsize=(60, 90))
fig.suptitle('Interest rate comparison between Wright data (orange) and our data (blue). Correlation in parentheses.', size=40)
plotrow = 0
for i in COUNTRY_CURRENCY_MAP.keys():
wright_df = wright_data[i]
own_df = own_data[i]
for y in [1, 2, 3, 4, 5]:
corr = np.round(own_df[[(y*12)]].merge(wright_df[[(y*12)]], left_index=True, right_index=True, validate='1:1').corr().iloc[0, 1], 4)
ax[plotrow, (y-1)].plot(own_df.index, own_df[(y*12)])
ax[plotrow, (y-1)].plot(wright_df.index, wright_df[y*12])
ax[plotrow, (y-1)].set_title('{} {}-year ({})'.format(i, y, corr), size=30)
ax[plotrow, (y-1)].tick_params(axis='both', which='major', labelsize=20)
plotrow = plotrow + 1
plt.show()