Vector Autoregression

Zhentao Shi

Sep 15, 2021

VAR

Specifcations

A VAR(p) system

\[ \mathbf y_t = \boldsymbol{\mu} + \mathbf{\Phi}_1 \mathbf{y}_{t-1} + \cdots + \mathbf{\Phi}_p y_{t-p} + \boldsymbol{\epsilon}_t \]

\[ \begin{align} y_{1t} & = \mu_1 + \phi_{11} y_{1,t-1} + \phi_{12} y_{2,t-1} + \epsilon_{1t} \\ y_{2t} & = \mu_2 + \phi_{21} y_{1,t-1} + \phi_{22} y_{2,t-1} + \epsilon_{2t} \end{align} \]

Estimation

Example

library(tsDyn) 
data(barry) 
barry <- barry[, c("cpiUSA", "cpiCAN")]
plot(barry)

Data processing and VAR regression

dbarry <- diff(barry)
plot(dbarry)

mreg <- lineVar(dbarry, lag = 3, model = "VAR")
print(mreg)
##                 Intercept cpiUSA -1   cpiCAN -1    cpiUSA -2  cpiCAN -2
## Equation cpiUSA 0.1089088 0.4678089 -0.04648345 -0.028101665 0.07909299
## Equation cpiCAN 0.0987480 0.2705002 -0.02301329 -0.004867705 0.19486643
##                   cpiUSA -3 cpiCAN -3
## Equation cpiUSA 0.007891732 0.0939838
## Equation cpiCAN 0.010717830 0.1536533

Information criteria

Impulse Response

\[ \begin{align} y_{1t} & = \mu_1 + \phi_{11} y_{1,t-1} + \phi_{12} y_{2,t-1} + \epsilon_{1t} \\ y_{2t} & = \mu_2 + \phi_{21} y_{1,t-1} + \phi_{22} y_{2,t-1} + (\rho \epsilon_{1t} + v_{2t}) \\ & = \tilde{\mu}_2 + \rho y_{1t} + \tilde{\phi}_{21} y_{1,t-1} + \tilde{\phi}_{22} y_{2,t-1} + v_{2t} \end{align} \]

Path of impact

\[ y_{1t} = \mu_1 + \phi_{11} y_{1,t-1} + \phi_{12} y_{2,t-1} + \epsilon_{1t}. \]

\[ \begin{align} \\ y_{2t} & = \tilde{\mu}_2 +\rho y_{1t} + \tilde{\phi}_{21} y_{1,t-1} + \tilde{\phi}_{22} y_{2,t-1} + v_{2t} \end{align} \]

Example

irf_var = irf(mreg, impulse = "cpiUSA", response = c("cpiUSA", "cpiCAN"), boot = FALSE)
print(irf_var)
## 
## Impulse response coefficients
## $cpiUSA
##            cpiUSA      cpiCAN
##  [1,] 0.154994135 0.060646708
##  [2,] 0.069688566 0.040530272
##  [3,] 0.031158080 0.028981581
##  [4,] 0.021399138 0.026299843
##  [5,] 0.014563998 0.017653617
##  [6,] 0.010441039 0.013341153
##  [7,] 0.007891908 0.010156895
##  [8,] 0.005755647 0.007318570
##  [9,] 0.004270164 0.005491120
## [10,] 0.003176343 0.004072063
## [11,] 0.002344197 0.003000950
plot(irf_var)

irf_var = irf(mreg, impulse = "cpiCAN", response = c("cpiUSA", "cpiCAN"), boot = FALSE)
print(irf_var)
## 
## Impulse response coefficients
## $cpiCAN
##             cpiUSA       cpiCAN
##  [1,]  0.000000000  0.227148412
##  [2,] -0.010558642 -0.005227431
##  [3,]  0.013269409  0.041527784
##  [4,]  0.025508725  0.036568544
##  [5,]  0.012570420  0.013169955
##  [6,]  0.011451505  0.016622132
##  [7,]  0.008911022  0.011112575
##  [8,]  0.005981957  0.007496385
##  [9,]  0.004731050  0.006244477
## [10,]  0.003462496  0.004370711
## [11,]  0.002529312  0.003245789
plot(irf_var)

Variance Decomposition

Let \(E_t[ \cdot]\) be the conditional expectation given all information contained from the start of the time up to the time \(t\).

\[ e_{1,T+1}:= y_{1,T+1} - E_T[y_{1,T+1}]. \]

\[ var[e_{1,T+1}] = var[\epsilon_{1,T+1}] = E_T[\epsilon^2_{1,T+1}] \]

\[ \begin{align} e_{2,T+1} & = & y_{2,T+1} - E_T[y_{2,T+1}] \\ & = & \tilde{\mu}_2 + \rho y_{1,T+1} + \tilde{\phi}_{21} y_{1T} + \tilde{\phi}_{22} y_{2T} + v_{2,T+1} \\ & & - (\tilde{\mu}_2 + \rho E_T[ y_{1,T+1} ] + \tilde{\phi}_{21} y_{2T} + \tilde{\phi}_{22} y_{2T}) \\ & = & \rho ( y_{1,T+1} - E_T[y_{1,T+1}] ) + v_{2,T+1} \\ & = & \rho \epsilon_{1,T+1} + v_{2,T+1} \end{align} \]

Thus \(var[e_{2,T+1}] = \rho^2 E_T[\epsilon_{1,T+1}^2] + E_T[ v_{2,T+1}^2].\)

Granger Causality

Example

library(lmtest)
data(ChickEgg)

# based on F-test
grangertest(egg ~ chicken, order = 3, data = ChickEgg)
## Granger causality test
## 
## Model 1: egg ~ Lags(egg, 1:3) + Lags(chicken, 1:3)
## Model 2: egg ~ Lags(egg, 1:3)
##   Res.Df Df      F Pr(>F)
## 1     44                 
## 2     47 -3 0.5916 0.6238
grangertest(chicken ~ egg, order = 3, data = ChickEgg)
## Granger causality test
## 
## Model 1: chicken ~ Lags(chicken, 1:3) + Lags(egg, 1:3)
## Model 2: chicken ~ Lags(chicken, 1:3)
##   Res.Df Df     F   Pr(>F)   
## 1     44                     
## 2     47 -3 5.405 0.002966 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Example (cont.)

Based on the Wald test

# based on Chi-square test
grangertest(egg ~ chicken, order = 3, data = ChickEgg, test = "Chisq")
## Granger causality test
## 
## Model 1: egg ~ Lags(egg, 1:3) + Lags(chicken, 1:3)
## Model 2: egg ~ Lags(egg, 1:3)
##   Res.Df Df  Chisq Pr(>Chisq)
## 1     44                     
## 2     47 -3 1.7748     0.6204
grangertest(chicken ~ egg, order = 3, data = ChickEgg, test = "Chisq")
## Granger causality test
## 
## Model 1: chicken ~ Lags(chicken, 1:3) + Lags(egg, 1:3)
## Model 2: chicken ~ Lags(chicken, 1:3)
##   Res.Df Df  Chisq Pr(>Chisq)   
## 1     44                        
## 2     47 -3 16.215   0.001025 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1