Using monthly data we previously found that there is a strong correlation between gold and real rates, so we investigate this on a finer time scale. We then use this correlation to help make forecasts using the univariate Holt-Winters method.
Dependencies:
- Linux, bash [not crucial, cross-platform prefered]
- Python: matplotlib, pandas [recommend Anaconda distribution]
- Modules: yi_1tools, yi_timeseries, yi_fred
CHANGE LOG
2015-03-10 Code review and revision.
2014-08-01 Use modules derived from notebooks.
2014-07-22 First satisfactory version.
# NOTEBOOK settings and system details: [00-tpl v14.09.28]
# Assume that the backend is LINUX (our particular distro is Ubuntu, running bash shell):
print '\n :: TIMESTAMP of last notebook execution:'
!date
print '\n :: IPython version:'
!ipython --version
# Automatically reload modified modules:
%load_ext autoreload
%autoreload 2
# 0 will disable autoreload.
# Generate plots inside notebook:
%matplotlib inline
# DISPLAY options
from IPython.display import Image
# e.g. Image(filename='holt-winters-equations.png', embed=True)
from IPython.display import YouTubeVideo
# e.g. YouTubeVideo('1j_HxD4iLn8')
from IPython.display import HTML # useful for snippets
# e.g. HTML('<iframe src=http://en.mobile.wikipedia.org/?useformat=mobile width=700 height=350></iframe>')
import pandas as pd
print '\n :: pandas version:'
print pd.__version__
# pandas DataFrames are represented as text by default; enable HTML representation:
# [Deprecated: pd.core.format.set_printoptions( notebook_repr_html=True ) ]
pd.set_option( 'display.notebook_repr_html', False )
# MATH display, use %%latex, rather than the following:
# from IPython.display import Math
# from IPython.display import Latex
print '\n :: Working directory (set as $workd):'
workd, = !pwd
print workd + '\n'
:: TIMESTAMP of last notebook execution: Thu Mar 12 14:20:08 PDT 2015 :: IPython version: 2.3.0 :: pandas version: 0.15.0 :: Working directory (set as $workd): /home/yaya/Dropbox/ipy/fecon235/nb
from yi_1tools import *
from yi_timeseries import *
from yi_fred import *
# Get gold and 10-y TIPS rates, both as daily frequency:
gold = getfred( d4xau )
tips = getfred( d4tips10 )
# The joint sample size is constrained by the more
# recent instrument TIPS issued by the US Treasury:
head( tips, 1 )
Y T 2003-01-02 2.43
Since 2003, there has been a strong inverse correlation between gold and TIPS: -87%. Gold becomes more attractive as an asset as real rates decline. When real rates are negative, then gold (which has no income stream) will preserve wealth.
Linear regression shows that since 2003 a decrease of 100 basis points in the TIPS yield implies an increase of $413 in gold price.
start = '2003-01-02'
start = '2007-01-02'
# Comment out this line to get earlier regression results.
# Do linear regression:
stat2( gold['Y'][start:], tips['Y'][start:] )
:: FIRST variable: count 2138.000000 mean 1210.443662 std 330.007724 min 608.400000 25% 921.187500 50% 1234.625000 75% 1456.812500 max 1895.000000 Name: Y, dtype: float64 :: SECOND variable: count 2137.000000 mean 0.916425 std 0.952471 min -0.870000 25% 0.250000 50% 0.850000 75% 1.640000 max 3.150000 Name: Y, dtype: float64 :: CORRELATION -0.913379014814 -------------------------Summary of Regression Analysis------------------------- Formula: Y ~ <x> + <intercept> Number of Observations: 2137 Number of Degrees of Freedom: 2 R-squared: 0.8343 Adj R-squared: 0.8342 Rmse: 134.4115 F-stat (1, 2135): 10746.7170, p-value: 0.0000 Degrees of Freedom: model 1, resid 2135 -----------------------Summary of Estimated Coefficients------------------------ Variable Coef Std Err t-stat p-value CI 2.5% CI 97.5% -------------------------------------------------------------------------------- x -316.5351 3.0534 -103.67 0.0000 -322.5198 -310.5505 intercept 1500.5516 4.0354 371.85 0.0000 1492.6423 1508.4609 ---------------------------------End of Summary---------------------------------
2015-03-10: The inverse relationship has become stronger since the Great Recession crisis (-91% correlation): TIPS +100 bp move implies a -$317 decrease in gold price.
tail( gold )
Y T 2015-03-04 1199.50 2015-03-05 1202.00 2015-03-06 1175.75 2015-03-09 1168.50 2015-03-10 1162.00 2015-03-11 1150.00 2015-03-12 1152.25
tail( tips )
Y T 2015-03-03 0.26 2015-03-04 0.25 2015-03-05 0.27 2015-03-06 0.41 2015-03-09 0.44 2015-03-10 0.41 2015-03-11 0.39
Regression summary: Depending on the timeframe specified by the start variable, the regression coefficient tells us that the price of gold decreases by about $365 (midpoint) for every 100 basis point rise in 10-year real rates (so roughly $90 decrease per quarter point rise).
August 2014 summary: From current levels where gold is at $1290 and TIPS yield 0.25%, we can expect gold to fall below $1000 if 10-year TIPS reach 1.25%. Note that $1000 gold is only $0.61 \sigma$ away from the 7-year mean of $1208. The long-term support point going back to 2005 is currently around $1260. It's not unreasonable for gold to breach long-term support if the Fed starts hiking rates up. The mean TIPS rate is 1.30% since its inception.
March 2015 summary: From current levels where gold is at $1162 and TIPS yield 0.25%, we can expect gold to fall below $1000 if the 10-year TIPS rate reach 0.75%. The Fed has ceased its QE quantitative easing program, and looks to raise rates soon, especially given that unemployment has decreased to the top of the Fed's NAIRU range ("non-accelerating inflation rate of unemployment"). USD has become extremely strong against all major currencies -- which further diminishes the appeal of gold.
# We resample gold monthly, and project out 12 months from now:
holtfred( monthly(gold), 12 )
Forecast 0 1175.750000 1 1195.296751 2 1189.081183 3 1182.865616 4 1176.650048 5 1170.434481 6 1164.218913 7 1158.003346 8 1151.787778 9 1145.572211 10 1139.356643 11 1133.141076 12 1126.925508
2015-03-10: Possible dramatic change in Fed policy (rate hikes) does not seem reflected in the projected decline in gold price.
# We resample TIPS monthly, and project out 12 months from now:
holtfred( monthly(tips), 12 )
Forecast 0 0.330000 1 0.288096 2 0.261604 3 0.235112 4 0.208620 5 0.182127 6 0.155635 7 0.129143 8 0.102651 9 0.076158 10 0.049666 11 0.023174 12 -0.003318
2015-03-10: Possible dramatic change in Fed policy (rate hikes) does not seem reflected in the projected decline into negative territory for TIPS rate. This 12-month projection to -0.06% (from 0.26% currently) would indicate a $95 increase in gold price to $1295.
Notes:
The directions of univariate forecasts may at times contradict the directions expected from the sign of correlation. In such cases, we suggest taking the average of point forecasts.
TIPS bond also reflects the current forward expectation of inflation in the next ten years.
Gold has soft lower boundaries, for example, the cost of production to produce new stock.
# 2005-03-12: average of between 12-m gold H-W forecast
# and 12-m gold extrapolated from H-W forecasted change in TIPS
# using regression coefficient [delta analysis]:
coef = -317
delta = coef * (-0.00-0.33)
(1127 + (tailvalue(gold) + delta)) / 2
1191.9299999999998