10. ∗ ## Causality tests
∗ ## Granger and instantaneous causality
∗ var.causal <- causality(varsimest, cause = "y2")
11. Forecasting
∗ ## Forecasting objects of class varest
∗ args(vars:::predict.varest)
∗ predictions <- predict(varsimest, n.ahead
= 25,
∗ ci = 0.95)
∗ class(predictions)
∗ args(vars:::plot.varprd)
∗ ## Plot of predictions for y1
∗ plot(predictions, names = "y1")
∗ ## Fanchart for y2
∗ args(fanchart)
∗ fanchart(predictions, names = "y2")
12. Impulse Response Function
∗ Causality test falls short of quantifying the impact of the
impulse variable on the response variable over time.
∗ The impulse response analysis is used to investigate these kinds
of dynamic interactions between the endogenous variables and
is based upon the Wold moving average representation of a
VAR(p)-process.
14. SVAR
∗ An SVAR-model can be used to identify shocks and trace these
out by employing IRA and/or FEVD through imposing
restrictions on the matrices A and/or B.
15. SVAR: A-model
∗ library(dse1) ∗ ## Obtaining the generated series
∗ library(vars) ∗ svardat <- matrix(svarsim$output, nrow = 500, ncol =
∗ ## A-model 2)
∗ colnames(svardat) <- c("y1", "y2")
∗ Apoly <- array(c(1.0, -0.5, 0.3, 0.8,
∗ ## Estimating the VAR
∗ 0.2, 0.1, -0.7, -0.2, ∗ varest <- VAR(svardat, p = 2, type = "none")
∗ 0.7, 1, 0.5, -0.3) , ∗ ## Setting up matrices for A-model
∗ c(3, 2, 2)) ∗ Amat <- diag(2)
∗ ## Setting covariance to identity-matrix ∗ Amat[2, 1] <- NA
∗ B <- diag(2) ∗ Amat[1, 2] <- NA
∗ ## Generating the VAR(2) model ∗ ## Estimating the SVAR A-type by direct
∗ svarA <- ARMA(A = Apoly, B = B) maximisation
∗ ## Simulating 500 observations ∗ ## of the log-likelihood
∗ svarsim <- simulate(svarA, sampleT = 500, ∗ args(SVAR)
∗ svar.A <- SVAR(varest, estmethod = "direct",
∗ rng = list(seed = c(123456)))
∗ Amat = Amat, hessian = TRUE)
16. SVAR: B-model
∗ library(dse1) ∗ ## Simulating 500 observations
∗ library(vars) ∗ svarsim <- simulate(svarB, sampleT = 500,
∗ ## B-model ∗ rng = list(seed = c(123456)))
∗ svardat <- matrix(svarsim$output, nrow = 500,
∗ Apoly <- array(c(1.0, -0.5, 0.3, 0, ncol = 2)
∗ 0.2, 0.1, 0, -0.2, ∗ colnames(svardat) <- c("y1", "y2")
∗ 0.7, 1, 0.5, -0.3) , ∗ varest <- VAR(svardat, p = 2, type = "none")
∗ c(3, 2, 2)) ∗ ## Estimating the SVAR B-type by scoring
algorithm
∗ ## Setting covariance to identity-matrix ∗ ## Setting up the restriction matrix and vector
∗ B <- diag(2) ∗ ## for B-model
∗ B[2, 1] <- -0.8 ∗ Bmat <- diag(2)
∗ ## Generating the VAR(2) model ∗ Bmat[2, 1] <- NA
∗ svarB <- ARMA(A = Apoly, B = B) ∗ svar.B <- SVAR(varest, estmethod = "scoring",
∗ Bmat = Bmat, max.iter = 200)