Exercise 7
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)
B
## [,1] [,2] [,3]
## [1,] 1 0 0
## [2,] 0 1 0
## [3,] 0 0 1
# Set up SVAR-model
svar2 <- ARMA(A = Apoly, B = B)
Exercise 8
- Simulating 250 observations and obtaining the generated series
set.seed(123456)
svarsim <- simulate(svar2, sampleT = 250, noise = list(w = matrix(rnorm(750),
nrow = 250, ncol = 3)))
svardat <- matrix(svarsim$output, nrow = 250, ncol = 3)
colnames(svardat) <- c("y1", "y2", "y3")
svarsimest <- VAR(svardat, p = 2, type = "none")
svarsimest
##
## VAR Estimation Results:
## =======================
##
## Estimated coefficients for equation y1:
## =======================================
## Call:
## y1 = y1.l1 + y2.l1 + y3.l1 + y1.l2 + y2.l2 + y3.l2
##
## y1.l1 y2.l1 y3.l1 y1.l2 y2.l2
## 0.5703960703 0.1023534420 0.0004917582 -0.3306940983 -0.1163272036
## y3.l2
## -0.0900427435
##
##
## Estimated coefficients for equation y2:
## =======================================
## Call:
## y2 = y1.l1 + y2.l1 + y3.l1 + y1.l2 + y2.l2 + y3.l2
##
## y1.l1 y2.l1 y3.l1 y1.l2 y2.l2 y3.l2
## -0.2404383 -0.5473169 -0.0662460 -0.1726524 0.2590978 0.1801948
##
##
## Estimated coefficients for equation y3:
## =======================================
## Call:
## y3 = y1.l1 + y2.l1 + y3.l1 + y1.l2 + y2.l2 + y3.l2
##
## y1.l1 y2.l1 y3.l1 y1.l2 y2.l2 y3.l2
## 0.36187388 0.52255168 -0.06019754 -0.34060011 0.11467007 -0.22178888
- Just identified AB matrix
Amat <- diag(3)
Amat[2, 1] <- NA
Amat[3, 2] <- NA
Amat[3, 1] <- NA
Bmat <- diag(3)
Bmat[1, 1] <- NA
Bmat[2, 2] <- NA
Bmat[3, 3] <- NA
# Estimating just identified SVAR AB-type by scoring algorithm
svar.i <- SVAR(svarsimest, estmethod = "scoring", Amat = Amat, Bmat = Bmat)
# estimattion method can be LM or scoring
svar.i
##
## SVAR Estimation Results:
## ========================
##
##
## Estimated A matrix:
## y1 y2 y3
## y1 1.0000 0.00000 0
## y2 0.1384 1.00000 0
## y3 0.1327 -0.02642 1
##
## Estimated B matrix:
## y1 y2 y3
## y1 0.9585 0.000 0.0000
## y2 0.0000 1.036 0.0000
## y3 0.0000 0.000 0.9451
Amatov <- diag(3)
Amatov[2, 1] <- NA
Amatov[3, 2] <- NA
Bmatov <- diag(3)
Bmatov[1, 1] <- NA
Bmatov[2, 2] <- NA
Bmatov[3, 3] <- NA
# Estimating overidentified SVAR AB-type by scoring algorithm
svar.ov <- SVAR(svarsimest, estmethod = "scoring", Amat = Amatov, Bmat = Bmatov)
svar.ov
##
## SVAR Estimation Results:
## ========================
##
##
## Estimated A matrix:
## y1 y2 y3
## y1 1.0000 0.00000 0
## y2 0.1384 1.00000 0
## y3 0.0000 -0.04189 1
##
## Estimated B matrix:
## y1 y2 y3
## y1 0.9585 0.000 0.0000
## y2 0.0000 1.036 0.0000
## y3 0.0000 0.000 0.9535
Exercise 9
- Impulse response analysis of overidentified SVAR
irf.svarov1 <- vars:::irf(svar.ov, impulse = "y1", response = c("y2", "y3"), n.ahead = 10,
ortho = TRUE, cumulative = FALSE, boot = TRUE, seed = 12345)
irf.svarov2 <- vars:::irf(svar.ov, impulse = "y2", response = c("y1", "y3"), n.ahead = 10,
ortho = TRUE, cumulative = FALSE, boot = TRUE, seed = 12345)
irf.svarov3 <- vars:::irf(svar.ov, impulse = "y3", response = c("y1", "y2"), n.ahead = 10,
ortho = TRUE, cumulative = FALSE, boot = TRUE, seed = 12345)
plot(irf.svarov1, plot.type = "multiple")

plot(irf.svarov2, plot.type = "multiple")

plot(irf.svarov3, plot.type = "multiple")

- Impulse response analysis of just identified SVAR
irf.svari1 <- vars:::irf(svar.i, impulse = "y1", response = c("y2", "y3"), n.ahead = 10,
ortho = TRUE, cumulative = FALSE, boot = TRUE, seed = 12345)
irf.svari2 <- vars:::irf(svar.i, impulse = "y2", response = c("y1", "y3"), n.ahead = 10,
ortho = TRUE, cumulative = FALSE, boot = TRUE, seed = 12345)
irf.svari3 <- vars:::irf(svar.i, impulse = "y3", response = c("y1", "y2"), n.ahead = 10,
ortho = TRUE, cumulative = FALSE, boot = TRUE, seed = 12345)
plot(irf.svari1, plot.type = "multiple")

plot(irf.svari2, plot.type = "multiple")

plot(irf.svari3, plot.type = "multiple")

- FEVD analysis of just identified SVAR AB-type model
fevd.svarov <- fevd(svar.i, n.ahead = 10)
plot(fevd.svarov, addbars = 2)
