Vector Autoregressive Models

Research in Finance

A VAR model is estimated in order to examine whether there are lead lag relationships between the returns to three exchange rates against the US dollar the euro, the British pound and the Japanese yen.

1 Packages:

library(tseries)
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo
library(vars)
## Loading required package: MASS
## Loading required package: strucchange
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
## Loading required package: sandwich
## Loading required package: urca
## Loading required package: lmtest

2 Import data:

library(readxl)
currencies <- read_excel("D:/Research in Finance/currencies.xls", col_types = c("date", "numeric", "numeric", "numeric"), na = "NA")
View(currencies)
  • The data are daily and run from 14 December 1998 to 3 July 2018, giving a total of 7,142 observations.

  • 3 exchange rate series: EUR/USD; GBP/USD; JPY/USD

3 Check stationary

3.1 Original data

adf.test(currencies$EUR)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  currencies$EUR
## Dickey-Fuller = -1.6103, Lag order = 19, p-value = 0.7434
## alternative hypothesis: stationary

p-value = 0.7 > 0.05–> Not stationary

adf.test(currencies$GBP)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  currencies$GBP
## Dickey-Fuller = -1.6029, Lag order = 19, p-value = 0.7466
## alternative hypothesis: stationary

p-value = 0.7 > 0.05–> Not stationary

adf.test(currencies$JPY)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  currencies$JPY
## Dickey-Fuller = -1.7792, Lag order = 19, p-value = 0.6719
## alternative hypothesis: stationary

p-value = 0.6719 > 0.05–> Not stationary

Because all of three series are not stationary, then we create the return (log-ret)

3.2 Log-ret series

currencies$reur = c(NA, 100 * diff(log(currencies$EUR)))
currencies$rgbp = c(NA, 100 * diff(log(currencies$GBP)))
currencies$rjpy = c(NA, 100 * diff(log(currencies$JPY)))
currencies = currencies[-1,]
adf.test(currencies$reur)
## Warning in adf.test(currencies$reur): p-value smaller than printed p-value
## 
##  Augmented Dickey-Fuller Test
## 
## data:  currencies$reur
## Dickey-Fuller = -18.535, Lag order = 19, p-value = 0.01
## alternative hypothesis: stationary
adf.test(currencies$rgbp)
## Warning in adf.test(currencies$rgbp): p-value smaller than printed p-value
## 
##  Augmented Dickey-Fuller Test
## 
## data:  currencies$rgbp
## Dickey-Fuller = -19.246, Lag order = 19, p-value = 0.01
## alternative hypothesis: stationary
adf.test(currencies$rjpy)
## Warning in adf.test(currencies$rjpy): p-value smaller than printed p-value
## 
##  Augmented Dickey-Fuller Test
## 
## data:  currencies$rjpy
## Dickey-Fuller = -18.927, Lag order = 19, p-value = 0.01
## alternative hypothesis: stationary

Since the p-value of all 3 series (reur, rjpy, rgbp) are less than 0.05 (0.01< 0.05), then all 3 return series in above are stationary.

Therefore, they can try with VAR (g= 3, k=?)

4 Run The VAR Model.

4.1 Run VAR (2):

VAR(currencies[c('reur', 'rgbp', 'rjpy')], p = 2)
## 
## VAR Estimation Results:
## ======================= 
## 
## Estimated coefficients for equation reur: 
## ========================================= 
## Call:
## reur = reur.l1 + rgbp.l1 + rjpy.l1 + reur.l2 + rgbp.l2 + rjpy.l2 + const 
## 
##       reur.l1       rgbp.l1       rjpy.l1       reur.l2       rgbp.l2 
##  0.1474965506 -0.0183557359 -0.0070978299 -0.0118082131  0.0066228786 
##       rjpy.l2         const 
## -0.0054272893  0.0001368541 
## 
## 
## Estimated coefficients for equation rgbp: 
## ========================================= 
## Call:
## rgbp = reur.l1 + rgbp.l1 + rjpy.l1 + reur.l2 + rgbp.l2 + rjpy.l2 + const 
## 
##      reur.l1      rgbp.l1      rjpy.l1      reur.l2      rgbp.l2      rjpy.l2 
## -0.025270542  0.221361804 -0.039016040  0.046926637 -0.067794083  0.003286917 
##        const 
##  0.002825689 
## 
## 
## Estimated coefficients for equation rjpy: 
## ========================================= 
## Call:
## rjpy = reur.l1 + rgbp.l1 + rjpy.l1 + reur.l2 + rgbp.l2 + rjpy.l2 + const 
## 
##       reur.l1       rgbp.l1       rjpy.l1       reur.l2       rgbp.l2 
##  0.0410612623 -0.0708456993  0.1324572148 -0.0188915075  0.0249075437 
##       rjpy.l2         const 
##  0.0149565492 -0.0004125908
VARselect(currencies[c('reur', 'rgbp', 'rjpy')], lag.max = 10)
## $selection
## AIC(n)  HQ(n)  SC(n) FPE(n) 
##      4      2      1      4 
## 
## $criteria
##                   1           2            3            4            5
## AIC(n) -5.433453428 -5.43726462 -5.437666647 -5.438909241 -5.438464346
## HQ(n)  -5.429472196 -5.43029747 -5.427713567 -5.425970237 -5.422539418
## SC(n)  -5.421888924 -5.41702674 -5.408755386 -5.401324601 -5.392206329
## FPE(n)  0.004367985  0.00435137  0.004349621  0.004344219  0.004346152
##                   6            7            8            9           10
## AIC(n) -5.437389700 -5.436794113 -5.435808057 -5.435335655 -5.433668221
## HQ(n)  -5.418478849 -5.414897337 -5.410925357 -5.407467031 -5.402813673
## SC(n)  -5.382458304 -5.373189339 -5.363529904 -5.354384124 -5.344043311
## FPE(n)  0.004350826  0.004353418  0.004357713  0.004359772  0.004367048

To find the best \(k\), using VAR models:

  • AIC: min AIC= -5.438909241 when k = 4.

  • HQ : min AIC = -5.43029747 when k =2

  • SC: min AIC = -5.421888924 when k = 1

–> Choose k = 1 for this example.

4.2 Run VAR(1)

According to the Schwarz Criterion, lag 1 is the optimal choice.

model= VAR(currencies[c('reur', 'rgbp', 'rjpy')], p = 1)

Granger test : \(y_{1}\ Granger\ test\ y_{2}\)

\[H_{0}:\ y_{1}\ does\ not\ Granger\ cause\ y_{2}?\]

\[H_{0}: \alpha_{12}= \beta_{12}= \sigma_{12}= 0\]

  • Using \(p-value = 0.3 > 0.05\),

\(\Rightarrow \ not\ reject\ H_{0}\)

\(\Rightarrow y_{1}\ does\ not\ Granger\ cause\ y_{2}\)

causality(model , cause = c('reur', 'rgbp'))$Granger
## 
##  Granger causality H0: reur rgbp do not Granger-cause rjpy
## 
## data:  VAR object model
## F-Test = 7.7511, df1 = 2, df2 = 21408, p-value = 0.0004315
causality(model, cause = c('reur'))$Granger
## 
##  Granger causality H0: reur do not Granger-cause rgbp rjpy
## 
## data:  VAR object model
## F-Test = 4.1141, df1 = 2, df2 = 21408, p-value = 0.01635
causality(model, cause = c('reur', 'rjpy'))$Granger
## 
##  Granger causality H0: reur rjpy do not Granger-cause rgbp
## 
## data:  VAR object model
## F-Test = 7.7007, df1 = 2, df2 = 21408, p-value = 0.0004537
grangertest(reur~rgbp, order = 1, data = currencies) 
## Granger causality test
## 
## Model 1: reur ~ Lags(reur, 1:1) + Lags(rgbp, 1:1)
## Model 2: reur ~ Lags(reur, 1:1)
##   Res.Df Df      F Pr(>F)
## 1   7137                 
## 2   7138 -1 0.9912 0.3195
grangertest(rjpy ~rgbp, order = 1, data = currencies) 
## Granger causality test
## 
## Model 1: rjpy ~ Lags(rjpy, 1:1) + Lags(rgbp, 1:1)
## Model 2: rjpy ~ Lags(rjpy, 1:1)
##   Res.Df Df    F  Pr(>F)   
## 1   7137                   
## 2   7138 -1 9.69 0.00186 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
grangertest(rgbp~reur, order = 1, data = currencies) 
## Granger causality test
## 
## Model 1: rgbp ~ Lags(rgbp, 1:1) + Lags(reur, 1:1)
## Model 2: rgbp ~ Lags(rgbp, 1:1)
##   Res.Df Df      F  Pr(>F)  
## 1   7137                    
## 2   7138 -1 3.8834 0.04881 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
grangertest(rjpy~reur, order = 1, data = currencies) 
## Granger causality test
## 
## Model 1: rjpy ~ Lags(rjpy, 1:1) + Lags(reur, 1:1)
## Model 2: rjpy ~ Lags(rjpy, 1:1)
##   Res.Df Df     F Pr(>F)
## 1   7137                
## 2   7138 -1 5e-04 0.9815
grangertest(rgbp~rjpy, order = 1, data = currencies) 
## Granger causality test
## 
## Model 1: rgbp ~ Lags(rgbp, 1:1) + Lags(rjpy, 1:1)
## Model 2: rgbp ~ Lags(rgbp, 1:1)
##   Res.Df Df      F    Pr(>F)    
## 1   7137                        
## 2   7138 -1 14.096 0.0001751 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
grangertest(reur~rjpy, order = 1, data = currencies) 
## Granger causality test
## 
## Model 1: reur ~ Lags(reur, 1:1) + Lags(rjpy, 1:1)
## Model 2: reur ~ Lags(reur, 1:1)
##   Res.Df Df      F Pr(>F)
## 1   7137                 
## 2   7138 -1 0.4202 0.5169

5 Impulse response:

ir= irf (model, n.ahead = 20)
plot(ir)

vd = fevd(model, n.ahead = 10) 
par(mar = c(1,1,1,1))
plot(vd)