The past several months have been difficult for watchers of the Canadian dollar and oil prices. Given that the Canadian economy is heavily reliant on natural resources and that oil is one of the largest exports, it seems reasonable to expect a strong relationship between commodity prices in general and oil prices in particular and Canadian exchange rates. Oil prices, which are priced in US dollars, can impact exchange rates through two different channels: the terms of trade effect or the wealth effect.
The chart below shows how many US dollars one Canadian dollar buys. Daily data from January 2, 1986 to February 6, 2015 are used to construct the chart.
The Canadian dollar has been fairly volatile over this time period, ranging from a low of 62 cents on January 18, 2002 to a high of $1.09 on November 7, 2007. As recently as September 2014, the Canadian dollar was trading over 90 cents. Once oil prices began to fall the Canadian dollar followed and within a few months was down below 80 cents.
For comparison purposes, here are what oil prices ($US/barrel) look like.
Before the year 2000, the oil price - Canadian dollar relationship was not as obvious. Since 2000, however, the relationship between the two has become much more pronounced. This correlation has given rise to the labeling of the Canadian dollar as a "petro-currency".
For completeness, here is a chart of the Toronto Stock Exchange (TSX). Notice that since 2000, the pattern of the TSX is similar to that of oil prices and exchange rates.
In order to more fully explore the relationship between oil prices and exchange rates, I conducted some rolling correlation analyses. A fixed window of 1260 days (approximately 5 years of trading days) was used to estimate the correlation between the daily returns of the exchange rate and oil prices. A rolling correlation analysis allows for sudden changes or jumps in the relationship between the two variables. A roiling analysis is a convenient way to see how stable a relationship is across time.
A chart of the rolling correlations between the Canadian dollar and oil prices (both measured in daily returns) shows how the relationship has strengthened across time. Across the sample period, the correlation between these two variables is mostly positive. In the 1990s, the correlation was never above 0.1. This indicates a fairly weak correlation between oil prices and the Canadian dollar. The relationship strengthened in the mid 2000s and after the 2008 - 2009 financial crisis. Today, the relationship remains moderate (between 0.4 and 0.5).
Here are what the rolling correlations look like for the other pairs of data. notice how the correlations have strengthened after the 2008 - 2009 financial crisis. The higher degree of correlations between different assets is one of the lasting effects of this crisis.
As a further analysis, I investigate the possibility of Granger causality from oil prices to exchange rates. A vector autoregression with 11 lags is used for the analysis. This model was stable and the residuals were approximately random. I use the same data set as in the previous charts. A rolling analysis is carried out on the causality test and the p values are plotted below. The purple line denotes a p value of 0.05. From the plot, evidence of causality from oil prices to exchange rates occurred at the beginning and end of the sample period. Overall, there does not seem to be much evidence of Granger causality running from oil prices to the Canadian dollar. The relationship between the two is probably more of a contemporaneous nature than a causal nature.
In summary, the relationship between oil prices and the Canadian dollar changes across time.This has implications for modelling, forecasting, and portfolio diversification.
Here is the R code to conduct the analysis. The rolling p value calculation takes about 15 minutes to complete.
#########################################################
# Economic forecasting and analysis
# Perry Sadorsky
# February 2015
# rolling correlations between FXcan and oil prices
# load data directly from FRED and Yahoo and merge
##########################################################
# load libraries
library(fpp)
library(quantmod)
# load data from Yahoo
symbols <- c( "^GSPTSE" )
getSymbols(symbols, from="1986-01-01", src='yahoo')
tsx = GSPTSE[, "GSPTSE.Adjusted", drop=F]
nrow(tsx)
# load data from FRED into new environment
symbol.vec = c("DCOILWTICO" , "DEXCAUS")
data <- new.env()
getSymbols(symbol.vec, src="FRED", env = data)
# fix up FRED data
na.locf(data$DCOILWTICO["1986-01-01::"])-> oil
1/na.locf(data$DEXCAUS["1986-01-01::"])-> fx
fred.merged = merge(oil,fx,join = "inner")
View(fred.merged)
nrow(fred.merged)
series.merged <- merge(fred.merged,tsx,join = "inner")
tail(series.merged)
tail(tsx)
tail(fx)
colnames(series.merged) <- c("oil", "fx", "TSX")
# View(series.merged)
# plot prices
par(mfrow=c(3,1))
plot(series.merged[,1], main="OIL ($US/bbl)")
plot(series.merged[,2], main="$US/$C")
plot(series.merged[,3], main="TSX")
par(mfrow=c(1,1))
# find min and max of fx
fx.min = which.min(series.merged[,2])
series.merged[fx.min,2]
fx.max = which.max(series.merged[,2])
series.merged[fx.max,2]
# calculate returns
ret = diff(log(series.merged)) * 100
tail(ret)
# plot returns
tsdisplay(ret[,1],main="Returns of oil")
tsdisplay(ret[,2],main="Returns of FX")
tsdisplay(ret[,3],main="Returns of TSX")
par(mfrow=c(1,1))
# 5 year rolling correlations, approximately 1260 days
rollout2 = rollapply(ret, 1260 ,function(x) cor(x[,1],x[,2]), by.column=FALSE,align="right")
rollout2 = na.omit(rollout2)
plot(rollout2,main="Rolling 5 year correlations between returns of FX and Oil")
rollout3 = rollapply(ret, 1260 ,function(x) cor(x[,1],x[,3]), by.column=FALSE,align="right")
rollout3 = na.omit(rollout3)
plot(rollout3,main="Rolling 5 year correlations between returns of Oil and TSX")
rollout4 = rollapply(ret, 1260 ,function(x) cor(x[,2],x[,3]), by.column=FALSE,align="right")
rollout4 = na.omit(rollout4)
plot(rollout4,main="Rolling 5 year correlations between returns of FX and TSX")
##########################################################
## some var modelling
##########################################################
library(vars)
ret = na.omit(ret)
# VAR modelling, select appropriate lag length
var1.s = VARselect(ret, lag.max = 26, type = "const")
str(var1.s)
lag = var1.s$selection[1]
var1 <- VAR(ret, p = lag, type = "const")
summary(var1)
roots(var1)
plot(var1)
par(mfrow=c(1,1))
# Granger causality tests
causality(var1, cause = "oil")
causality(var1, cause = "fx")
causality(var1, cause = "TSX")
# impulse response functions
var1.irf <- irf(var1, n.ahead = 20, boot = TRUE, cumulative= TRUE)
plot(var1.irf)
par(mfrow=c(1,1))
library(MSBVAR)
gt1 = granger.test(ret,p=11)
str(gt1)
gt1[3,2]
roll.gt = function(x) {
gt1 = granger.test(x,p=lag)
gt.p = gt1[3,2]
return(gt.p)
}
tic <- Sys.time()
roll.gt.pvals = rollapply(ret, width=1260,
by.column=FALSE,
FUN=roll.gt,
align="right")
toc <- Sys.time()
( toc - tic )
roll.gt.pvals = na.omit(roll.gt.pvals)
plot(roll.gt.pvals,main="Causality p values (oil > fx)")
abline(h=0.05,col="purple")