Question 1

Exercise 1

A three-dimensional VAR(2)-process where the third variable does not Granger-cause the first variable was generated using the following model:

\[\left[ \begin{array}{c} y_{1t} \\ y_{2t} \\ y_{3t} \end{array} \right] = \left[ \begin{array}{c} 5 \\ 10 \\ 15 \end{array} \right] + \left[ \begin{array}{ccc} -0.5 & -0.1 & 0 \\ 0.2 & 0.5 & 0.2 \\ -0.4 & -0.6 & 0.1 \end{array} \right] \left[ \begin{array}{c} y_{1t-1} \\ y_{2t-1} \\ y_{3t-1} \end{array} \right] + \left[ \begin{array}{ccc} 0.3 & 0.1 & 0 \\ 0.1 & -0.3 & -0.1 \\ 0.3 & -0.2 & 0.3 \end{array} \right] \left[ \begin{array}{c} y_{1t-2} \\ y_{2t-2} \\ y_{3t-2} \end{array} \right] + \left[ \begin{array}{c} u_{1t} \\ u_{2t} \\ u_{3t} \end{array} \right]\]

In a three-equation model with 2 lags \(\{y_{3t}\}\) does not Granger-cause \(\{y_{1t}\}\), if and only if all of the coefficients of \(A_{13}(L)\) are equal to zero.

\[A_{13}^{(1)}=A_{13}^{(2)}=0\]

  • Setting lag polynomial A(L)
Apoly <- array(c(1.0, -0.5, 0.3, 0.0, 0.2, 0.1, 0.0, -0.4, 0.3, 
                 0.0, -0.1, 0.1, 1.0, 0.5, -0.3, 0.0, -0.6, -0.2, 
                 0.0, 0.0, 0.0, 0.0, 0.1, -0.1, 1.0, 0.1, 0.3), 
               c(3, 3, 3))
  • Setting the corvariance to identity matrix
B <- diag(3)
  • Setting constant terms to 5, 10, and 15
TRD <- c(5, 10, 15)
  • Generating the VAR(2) model
var2 <- ARMA(A = Apoly, B = B, TREND = TRD)
var2
## TREND=   5 10 15
## A(L) =
## 1-0.5L1+0.3L2    0-0.1L1+0.1L2    0    
## 0+0.2L1+0.1L2    1+0.5L1-0.3L2    0+0.1L1-0.1L2    
## 0-0.4L1+0.3L2    0-0.6L1-0.2L2    1+0.1L1+0.3L2    
## 
## B(L) =
## 1    0    0    
## 0    1    0    
## 0    0    1

Exercise 2

  • Simulating 250 observations of the VAR(2) model:
set.seed(123456)
varsim <- simulate(var2, sampleT = 250, noise = list(w = matrix(rnorm(750), 
                                                                nrow = 250, ncol = 3))) 
  • Obtaining the generated series
vardat <- matrix(varsim$output, nrow = 250, ncol = 3) 
colnames(vardat) <- c("y1", "y2", "y3") 
  • Determining an appropriate lag order
VARselect(vardat, lag.max = 3, type = "const") 
## $selection
## AIC(n)  HQ(n)  SC(n) FPE(n) 
##      2      2      2      2 
## 
## $criteria
##                1           2          3
## AIC(n) 0.4787110 -0.03148530 0.02162564
## HQ(n)  0.5473543  0.08864042 0.19323381
## SC(n)  0.6492076  0.26688375 0.44786714
## FPE(n) 1.6140064  0.96904934 1.02199694
VARselect(vardat, lag.max = 3, type = NULL) 
## $selection
## AIC(n)  HQ(n)  SC(n) FPE(n) 
##      2      2      2      2 
## 
## $criteria
##                1           2          3
## AIC(n) 0.4787110 -0.03148530 0.02162564
## HQ(n)  0.5473543  0.08864042 0.19323381
## SC(n)  0.6492076  0.26688375 0.44786714
## FPE(n) 1.6140064  0.96904934 1.02199694
# All criteria indicate a lag order of two.

Exercise 3

  • Estimating the model
# Estimating the model with a constant
varsimest <- VAR(vardat, p = 2, type = "const", season = NULL, exogen = NULL)

# Alternatively, selection according to AIC
varsimest <- VAR(vardat, type = "const", lag.max = 3, ic = "SC")
summary(varsimest)
## 
## VAR Estimation Results:
## ========================= 
## Endogenous variables: y1, y2, y3 
## Deterministic variables: const 
## Sample size: 248 
## Log Likelihood: -1029.4 
## Roots of the characteristic polynomial:
## 0.7685 0.6023 0.6023 0.4971 0.4506 0.4506
## Call:
## VAR(y = vardat, type = "const", lag.max = 3, ic = "SC")
## 
## 
## Estimation results for equation y1: 
## =================================== 
## y1 = y1.l1 + y2.l1 + y3.l1 + y1.l2 + y2.l2 + y3.l2 + const 
## 
##       Estimate Std. Error t value Pr(>|t|)    
## y1.l1  0.56493    0.06074   9.301  < 2e-16 ***
## y2.l1  0.10478    0.05502   1.904   0.0580 .  
## y3.l1 -0.02379    0.05222  -0.455   0.6492    
## y1.l2 -0.31282    0.06492  -4.819 2.56e-06 ***
## y2.l2 -0.10376    0.06261  -1.657   0.0988 .  
## y3.l2 -0.08498    0.04760  -1.785   0.0755 .  
## const  6.30580    1.28401   4.911 1.67e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## 
## Residual standard error: 0.9606 on 241 degrees of freedom
## Multiple R-Squared: 0.2897,  Adjusted R-squared: 0.272 
## F-statistic: 16.38 on 6 and 241 DF,  p-value: 8.207e-16 
## 
## 
## Estimation results for equation y2: 
## =================================== 
## y2 = y1.l1 + y2.l1 + y3.l1 + y1.l2 + y2.l2 + y3.l2 + const 
## 
##       Estimate Std. Error t value Pr(>|t|)    
## y1.l1 -0.23882    0.06598  -3.619 0.000360 ***
## y2.l1 -0.54438    0.05977  -9.109  < 2e-16 ***
## y3.l1 -0.04673    0.05673  -0.824 0.410950    
## y1.l2 -0.18688    0.07052  -2.650 0.008580 ** 
## y2.l2  0.23491    0.06801   3.454 0.000652 ***
## y3.l2  0.17855    0.05170   3.453 0.000654 ***
## const  9.56623    1.39477   6.859 5.81e-11 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## 
## Residual standard error: 1.043 on 241 degrees of freedom
## Multiple R-Squared: 0.4981,  Adjusted R-squared: 0.4856 
## F-statistic: 39.86 on 6 and 241 DF,  p-value: < 2.2e-16 
## 
## 
## Estimation results for equation y3: 
## =================================== 
## y3 = y1.l1 + y2.l1 + y3.l1 + y1.l2 + y2.l2 + y3.l2 + const 
## 
##       Estimate Std. Error t value Pr(>|t|)    
## y1.l1  0.36032    0.06026   5.979 8.02e-09 ***
## y2.l1  0.52618    0.05458   9.640  < 2e-16 ***
## y3.l1 -0.06320    0.05181  -1.220   0.2237    
## y1.l2 -0.33359    0.06440  -5.180 4.69e-07 ***
## y2.l2  0.10260    0.06211   1.652   0.0999 .  
## y3.l2 -0.22879    0.04722  -4.845 2.26e-06 ***
## const 15.04797    1.27385  11.813  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## 
## Residual standard error: 0.953 on 241 degrees of freedom
## Multiple R-Squared: 0.452,   Adjusted R-squared: 0.4384 
## F-statistic: 33.13 on 6 and 241 DF,  p-value: < 2.2e-16 
## 
## 
## 
## Covariance matrix of residuals:
##         y1       y2       y3
## y1  0.9228 -0.12476 -0.12385
## y2 -0.1248  1.08888  0.04121
## y3 -0.1238  0.04121  0.90826
## 
## Correlation matrix of residuals:
##         y1       y2       y3
## y1  1.0000 -0.12446 -0.13528
## y2 -0.1245  1.00000  0.04144
## y3 -0.1353  0.04144  1.00000

  • Stability Tests
# H0: Stable regression relationship in VAR(p)
ols.cusum <- stability(varsimest, type = "OLS-CUSUM") 
dev.new()
plot(ols.cusum, names = "y1")
plot(ols.cusum, names = "y2")
plot(ols.cusum, names = "y3")
fluctuation <- stability(varsimest, type = "fluctuation")
dev.new()
plot(fluctuation, names = "y1")
plot(fluctuation, names = "y2")
plot(fluctuation, names = "y3")
# Neither test indicates structural instability
  • Checking the roots
roots <- roots(varsimest)
roots
## [1] 0.7685359 0.6022644 0.6022644 0.4970824 0.4505562 0.4505562

Since all the roots are less than 1, the stability condition is confirmed

Exercise 4

  • Testing for Serial Correlation
# Portmanteau Statistic
var2c.serial <- serial.test(varsimest, lags.pt = 16, type = "PT.asymptotic")
var2c.serial
## 
##  Portmanteau Test (asymptotic)
## 
## data:  Residuals of VAR object varsimest
## Chi-squared = 115.72, df = 126, p-value = 0.7335
# H0: B1 = ... = Bh = 0 (no serial correlation) 
# the null is not rejected as p-vale > 0.05. Thus the model is free from serial correlation. 
  • Testing for Heteroscedasity
# Multivariate ARCH-LM test
var2c.arch <- arch.test(varsimest, lags.multi = 5, multivariate.only = TRUE)
# H0: Homoskedasticity. Null hypothesis is not rejected as p-value > 0.05. 
  • Heteroskedasticity is not present.

  • Testing for normality

var2c.norm <- normality.test(varsimest, multivariate.only = TRUE)
# H0: Residuals are normally distributed 
# Null is not rejected as p-value > 0.05.  
  • Hence residuals of the model are independantly distributed.
  • Therefore none of the test outcomes indicates any deviations from a spherical error process.
dev.new()
plot(var2c.serial, names = "y1")
plot(var2c.serial, names = "y2")
plot(var2c.serial, names = "y3")

Exercise 5

  • Granger and Instantaneuos Casuality
var.causal <- causality(varsimest, cause = "y3")
var.causal
## $Granger
## 
##  Granger causality H0: y3 do not Granger-cause y1 y2
## 
## data:  VAR object varsimest
## F-Test = 3.6899, df1 = 4, df2 = 723, p-value = 0.005531
## 
## 
## $Instant
## 
##  H0: No instantaneous causality between: y3 and y1 y2
## 
## data:  VAR object varsimest
## Chi-squared = 4.6039, df = 2, p-value = 0.1001
# Null hypothesis of y3 does not granger cause y1 and y2 is rejected as p-value < 0.05. 
# Hence, y3 does grange-cause y1 and y2, jointly.
# However, the null hypothesis of no instantaneous causality between y3 
# and y1, y2 is not rejected as p-value > 0.05. 

granger.test(vardat, p = 2)
##          F-statistic      p-value
## y2 -> y1    8.699293 2.244241e-04
## y3 -> y1    2.684957 7.024823e-02
## y1 -> y2   15.881502 3.294081e-07
## y3 -> y2    6.086470 2.634851e-03
## y1 -> y3   16.135224 2.632522e-07
## y2 -> y3   50.322462 0.000000e+00
  • when Granger causality is tested individually, as expected, Y3 does not Granger-cause to y1.
  • There is a significant Causality runs from Y2 to Y3, individually.
  • Y3 does Granger cause Y1 and Y2, jointly.

Exercise 6

  • Impulse Response Analysis
# non-orthogonal
irf.y1 <- vars:::irf(varsimest, impulse ="y1", response = c("y2", "y3"),
                     n.ahead = 10, ortho = FALSE, cumulative = FALSE, boot = FALSE, seed = 12345)

irf.y2 <- vars:::irf(varsimest, impulse ="y2", response = c("y1", "y3"), 
                     n.ahead = 10, ortho = FALSE, cumulative = FALSE, boot = FALSE, seed = 12345)

irf.y3 <- vars:::irf(varsimest, impulse ="y3", response = c("y1", "y2"), 
                     n.ahead = 10, ortho = FALSE, cumulative = FALSE, boot = FALSE, seed = 12345)
dev.new()
plot(irf.y1)
plot(irf.y2)
plot(irf.y3)
# orthogonal
irf.y1 <- vars:::irf(varsimest, impulse ="y1", response = c("y2", "y3"), 
                     n.ahead = 10, ortho = FALSE,cumulative = FALSE, boot = TRUE, seed = 12345)

irf.y2 <- vars:::irf(varsimest, impulse ="y2", response = c("y1", "y3"), 
                     n.ahead = 10, ortho = FALSE,cumulative = FALSE, boot = TRUE, seed = 12345)

irf.y3 <- vars:::irf(varsimest, impulse ="y3", response = c("y1", "y2"), 
                     n.ahead = 10, ortho = FALSE,cumulative = FALSE, boot = TRUE, seed = 12345)
  • All responses show that there are no effects in lag 1 shocks from y1 and y3 to y2 are negative in lag two, whereas others shows positive impacts Thereafter, both positive and negative responses are occured.

  • Forecast Error Variance Decomposition

fevd.var2 <- fevd(varsimest, n.ahead=10)
plot(fevd.var2, addbars = 2)

  • Up to 10 period ahead , variance of y1 and y2 are mostly explained by y1 and y2 itself.
  • Forecast error of y3 is mainly expolained by y3 in the first lag and thereafter its explanation power decreases.