#Question 1

The problem asks us to;

  1. Estimate a bivariate reduced form VAR for y[t] =(y1,t, y2,t)’for the periods 1951Q1 to 2014Q4 using information criteria. To find the extent of correlation of residuals in model and implications.

  2. Run the Granger Causality Test.

  3. Estimating two restricted VAR models for removing the lags based on Granger Causality Test and for removing variables having t-statistics less than 2.

  4. Estimating the results found in above problems using Stargazer package.

e)Plot IRFs and FEVD for VAR models based on Choleski decomoposition and reversing the order after that.

Source of the data is Quandle and data are; FRED/GDPC1 for real GDP, FRED/GDPDF for GDP deflator and YAHOO/INDEX_GSPC for closing value of S&P 500 Index.

#Methodology
#a) Estimating Bivariate Reduced Form.
library(zoo)
## Warning: package 'zoo' was built under R version 3.2.4
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
library(Quandl)
## Warning: package 'Quandl' was built under R version 3.2.4
## Loading required package: xts
## Warning: package 'xts' was built under R version 3.2.4
library(stargazer)
## 
## Please cite as:
##  Hlavac, Marek (2015). stargazer: Well-Formatted Regression and Summary Statistics Tables.
##  R package version 5.2. http://CRAN.R-project.org/package=stargazer
library(vars)
## Warning: package 'vars' was built under R version 3.2.4
## Loading required package: MASS
## Loading required package: strucchange
## Warning: package 'strucchange' was built under R version 3.2.4
## Loading required package: sandwich
## Warning: package 'sandwich' was built under R version 3.2.4
## Loading required package: urca
## Warning: package 'urca' was built under R version 3.2.4
## Loading required package: lmtest
## Warning: package 'lmtest' was built under R version 3.2.4
Growth <- Quandl("FRED/GDPC1", api_key="T8gDpM8iFjXR9pfbXBmx",type = "zoo")
Deflator <- Quandl("FRED/GDPDEF", api_key="T8gDpM8iFjXR9pfbXBmx",type="zoo")
mIndex <- Quandl("YAHOO/INDEX_GSPC", api_key="T8gDpM8iFjXR9pfbXBmx", type ="zoo")
Index <- aggregate(mIndex[,4],as.yearqtr,tail,1)
v1 <- diff(log(Growth))
ddeflator <- diff(log(Deflator))
dindex <- diff(log(Index[,4]))
v2 <- dindex-ddeflator

Now, plotting the data so that we can be acquainted with the mode of path of data.

plot(v1, xlab="Years", ylab="GDP Rate", main="GDP TREND")

plot(v2, xlab=" Years", ylab="", main="Adjusted Return")

Now, estimating the VAR model using information criteria.

V.Q <- cbind(v1, v2)
V.Q <- window(V.Q, start="1951 Q1", end="2014 Q4")
VARselect(V.Q, lag.max=12, type="const")
## $selection
## AIC(n)  HQ(n)  SC(n) FPE(n) 
##      2      2      2      2 
## 
## $criteria
##                    1             2             3             4
## AIC(n) -1.465325e+01 -1.471119e+01 -1.469918e+01 -1.467160e+01
## HQ(n)  -1.461861e+01 -1.465347e+01 -1.461837e+01 -1.456770e+01
## SC(n)  -1.456725e+01 -1.456786e+01 -1.449852e+01 -1.441361e+01
## FPE(n)  4.326904e-07  4.083345e-07  4.132760e-07  4.248476e-07
##                    5             6             7             8
## AIC(n) -1.465637e+01 -1.463471e+01 -1.462541e+01 -1.459590e+01
## HQ(n)  -1.452938e+01 -1.448462e+01 -1.445223e+01 -1.439963e+01
## SC(n)  -1.434106e+01 -1.426206e+01 -1.419543e+01 -1.410858e+01
## FPE(n)  4.313906e-07  4.408750e-07  4.450429e-07  4.584370e-07
##                    9            10            11            12
## AIC(n) -1.458248e+01 -1.456467e+01 -1.455515e+01 -1.454714e+01
## HQ(n)  -1.436313e+01 -1.432222e+01 -1.428962e+01 -1.425852e+01
## SC(n)  -1.403784e+01 -1.396269e+01 -1.389585e+01 -1.383051e+01
## FPE(n)  4.647120e-07  4.731697e-07  4.778199e-07  4.818181e-07

From the above table, we found that AIC at lag 2 is minimum and we will use that lag to calculate VAR in reduced form.

var1 <- VAR(V.Q, p=2, type="const")
summary(var1)
## 
## VAR Estimation Results:
## ========================= 
## Endogenous variables: v1, v2 
## Deterministic variables: const 
## Sample size: 254 
## Log Likelihood: 1154.493 
## Roots of the characteristic polynomial:
## 0.4454 0.4454 0.304 0.304
## Call:
## VAR(y = V.Q, p = 2, type = "const")
## 
## 
## Estimation results for equation v1: 
## =================================== 
## v1 = v1.l1 + v2.l1 + v1.l2 + v2.l2 + const 
## 
##        Estimate Std. Error t value Pr(>|t|)    
## v1.l1 0.2450402  0.0614771   3.986 8.84e-05 ***
## v2.l1 0.0230968  0.0064046   3.606 0.000375 ***
## v1.l2 0.0793493  0.0595434   1.333 0.183872    
## v2.l2 0.0263004  0.0065720   4.002 8.29e-05 ***
## const 0.0046278  0.0007233   6.398 7.75e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## 
## Residual standard error: 0.008038 on 249 degrees of freedom
## Multiple R-Squared: 0.2309,  Adjusted R-squared: 0.2185 
## F-statistic: 18.68 on 4 and 249 DF,  p-value: 1.91e-13 
## 
## 
## Estimation results for equation v2: 
## =================================== 
## v2 = v1.l1 + v2.l1 + v1.l2 + v2.l2 + const 
## 
##        Estimate Std. Error t value Pr(>|t|)  
## v1.l1  0.256054   0.609111   0.420   0.6746  
## v2.l1  0.106501   0.063457   1.678   0.0945 .
## v1.l2 -0.819353   0.589953  -1.389   0.1661  
## v2.l2 -0.040573   0.065115  -0.623   0.5338  
## const  0.013836   0.007167   1.931   0.0547 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## 
## Residual standard error: 0.07964 on 249 degrees of freedom
## Multiple R-Squared: 0.02087, Adjusted R-squared: 0.00514 
## F-statistic: 1.327 on 4 and 249 DF,  p-value: 0.2605 
## 
## 
## 
## Covariance matrix of residuals:
##          v1       v2
## v1 6.46e-05 0.000087
## v2 8.70e-05 0.006342
## 
## Correlation matrix of residuals:
##        v1     v2
## v1 1.0000 0.1359
## v2 0.1359 1.0000

From the table, we found that the correlation between residuals of v1t and v2t to be 0.1359. This means there is some sort of causal relationship between two variables. Let’s test by Granger Causality test to know whether V1 has causal effect on V2.

#b) Granger Causality Test
causality(var1, cause="v1")
## $Granger
## 
##  Granger causality H0: v1 do not Granger-cause v2
## 
## data:  VAR object var1
## F-Test = 0.96654, df1 = 2, df2 = 498, p-value = 0.3811
## 
## 
## $Instant
## 
##  H0: No instantaneous causality between: v1 and v2
## 
## data:  VAR object var1
## Chi-squared = 4.6072, df = 1, p-value = 0.03184
causality(var1, cause="v2")
## $Granger
## 
##  Granger causality H0: v2 do not Granger-cause v1
## 
## data:  VAR object var1
## F-Test = 15.762, df1 = 2, df2 = 498, p-value = 2.305e-07
## 
## 
## $Instant
## 
##  H0: No instantaneous causality between: v2 and v1
## 
## data:  VAR object var1
## Chi-squared = 4.6072, df = 1, p-value = 0.03184

The table doesnt show the causality between V1 and V2 in both direction.

#c) Restricted VAR Analysis
r.mat <- matrix(1, nrow=2, ncol=5)

r.varp <- restrict(var1, method="manual", resmat=r.mat)
summary(r.varp)
## 
## VAR Estimation Results:
## ========================= 
## Endogenous variables: v1, v2 
## Deterministic variables: const 
## Sample size: 254 
## Log Likelihood: 1154.493 
## Roots of the characteristic polynomial:
## 0.4454 0.4454 0.304 0.304
## Call:
## VAR(y = V.Q, p = 2, type = "const")
## 
## 
## Estimation results for equation v1: 
## =================================== 
## v1 = v1.l1 + v2.l1 + v1.l2 + v2.l2 + const 
## 
##        Estimate Std. Error t value Pr(>|t|)    
## v1.l1 0.2450402  0.0614771   3.986 8.84e-05 ***
## v2.l1 0.0230968  0.0064046   3.606 0.000375 ***
## v1.l2 0.0793493  0.0595434   1.333 0.183872    
## v2.l2 0.0263004  0.0065720   4.002 8.29e-05 ***
## const 0.0046278  0.0007233   6.398 7.75e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## 
## Residual standard error: 0.008038 on 249 degrees of freedom
## Multiple R-Squared: 0.5479,  Adjusted R-squared: 0.5388 
## F-statistic: 60.35 on 5 and 249 DF,  p-value: < 2.2e-16 
## 
## 
## Estimation results for equation v2: 
## =================================== 
## v2 = v1.l1 + v2.l1 + v1.l2 + v2.l2 + const 
## 
##        Estimate Std. Error t value Pr(>|t|)  
## v1.l1  0.256054   0.609111   0.420   0.6746  
## v2.l1  0.106501   0.063457   1.678   0.0945 .
## v1.l2 -0.819353   0.589953  -1.389   0.1661  
## v2.l2 -0.040573   0.065115  -0.623   0.5338  
## const  0.013836   0.007167   1.931   0.0547 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## 
## Residual standard error: 0.07964 on 249 degrees of freedom
## Multiple R-Squared: 0.03656, Adjusted R-squared: 0.01721 
## F-statistic:  1.89 on 5 and 249 DF,  p-value: 0.09665 
## 
## 
## 
## Covariance matrix of residuals:
##          v1       v2
## v1 6.46e-05 0.000087
## v2 8.70e-05 0.006342
## 
## Correlation matrix of residuals:
##        v1     v2
## v1 1.0000 0.1359
## v2 0.1359 1.0000
r.varp$restrictions
##    v1.l1 v2.l1 v1.l2 v2.l2 const
## v1     1     1     1     1     1
## v2     1     1     1     1     1
Acoef(r.varp)
## [[1]]
##        v1.l1      v2.l1
## v1 0.2450402 0.02309677
## v2 0.2560542 0.10650115
## 
## [[2]]
##          v1.l2       v2.l2
## v1  0.07934933  0.02630040
## v2 -0.81935297 -0.04057338
r.varp.ser <- restrict(var1, method="ser", thresh=2.0)
summary(r.varp.ser)
## 
## VAR Estimation Results:
## ========================= 
## Endogenous variables: v1, v2 
## Deterministic variables: const 
## Sample size: 254 
## Log Likelihood: 1150.599 
## Roots of the characteristic polynomial:
## 0.2734     0     0     0
## Call:
## VAR(y = V.Q, p = 2, type = "const")
## 
## 
## Estimation results for equation v1: 
## =================================== 
## v1 = v1.l1 + v2.l1 + v2.l2 + const 
## 
##        Estimate Std. Error t value Pr(>|t|)    
## v1.l1 0.2734178  0.0577607   4.734 3.70e-06 ***
## v2.l1 0.0226323  0.0064051   3.533 0.000488 ***
## v2.l2 0.0266285  0.0065775   4.048 6.88e-05 ***
## const 0.0050198  0.0006618   7.585 6.55e-13 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## 
## Residual standard error: 0.00805 on 250 degrees of freedom
## Multiple R-Squared: 0.5446,  Adjusted R-squared: 0.5374 
## F-statistic: 74.76 on 4 and 250 DF,  p-value: < 2.2e-16 
## 
## 
## Estimation results for equation v2: 
## =================================== 
## v2 = const 
## 
##       Estimate Std. Error t value Pr(>|t|)  
## const  0.01017    0.00501    2.03   0.0434 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## 
## Residual standard error: 0.07984 on 253 degrees of freedom
## Multiple R-Squared: 0.01602, Adjusted R-squared: 0.01213 
## F-statistic: 4.119 on 1 and 253 DF,  p-value: 0.04344 
## 
## 
## 
## Covariance matrix of residuals:
##           v1        v2
## v1 6.506e-05 8.224e-05
## v2 8.224e-05 6.477e-03
## 
## Correlation matrix of residuals:
##        v1     v2
## v1 1.0000 0.1267
## v2 0.1267 1.0000
r.varp.ser$restrictions
##    v1.l1 v2.l1 v1.l2 v2.l2 const
## v1     1     1     0     1     1
## v2     0     0     0     0     1
Acoef(r.varp.ser)
## [[1]]
##        v1.l1      v2.l1
## v1 0.2734178 0.02263225
## v2 0.0000000 0.00000000
## 
## [[2]]
##    v1.l2      v2.l2
## v1     0 0.02662845
## v2     0 0.00000000
#d) Stargazer
lmp1 <- var1$varresult
lmnp <- r.varp$varresult
lmse <- r.varp.ser$varresult
stargazer(lmp1$v1, lmp1$v2, lmnp$v1, lmnp$v2, type="text", title="", align=TRUE, header=FALSE, model.numbers=TRUE,dep.var.caption="", result="Niraj", column.labels=c("VAR1-v1","VAR1-v2","VARP-v1", "VARP-v2"))
## 
## =======================================================================================================================
##                                                                           y                                            
##                                        VAR1-v1               VAR1-v2               VARP-v1               VARP-v2       
##                                          (1)                   (2)                   (3)                   (4)         
## -----------------------------------------------------------------------------------------------------------------------
## v1.l1                                 0.245***                0.256               0.245***                0.256        
##                                        (0.061)               (0.609)               (0.061)               (0.609)       
##                                                                                                                        
## v2.l1                                 0.023***               0.107*               0.023***                0.107*       
##                                        (0.006)               (0.063)               (0.006)               (0.063)       
##                                                                                                                        
## v1.l2                                   0.079                -0.819                 0.079                 -0.819       
##                                        (0.060)               (0.590)               (0.060)               (0.590)       
##                                                                                                                        
## v2.l2                                 0.026***               -0.041               0.026***                -0.041       
##                                        (0.007)               (0.065)               (0.007)               (0.065)       
##                                                                                                                        
## const                                 0.005***               0.014*               0.005***                0.014*       
##                                        (0.001)               (0.007)               (0.001)               (0.007)       
##                                                                                                                        
## -----------------------------------------------------------------------------------------------------------------------
## Observations                             254                   254                   254                   254         
## R2                                      0.231                 0.021                 0.548                 0.037        
## Adjusted R2                             0.219                 0.005                 0.539                 0.017        
## Residual Std. Error (df = 249)          0.008                 0.080                 0.008                 0.080        
## F Statistic                    18.685*** (df = 4; 249) 1.327 (df = 4; 249) 60.345*** (df = 5; 249) 1.890* (df = 5; 249)
## =======================================================================================================================
## Note:                                                                                       *p<0.1; **p<0.05; ***p<0.01
## 
## =====
## Niraj
## -----
stargazer(lmse$v1, lmse$v2, type="text", title="", 
           align=TRUE, header=FALSE, model.numbers=TRUE,
           dep.var.caption="", result="Niraj", column.labels=c("VARP.SER-v1","VARP.SER-v2"))
## 
## =================================================================
##                                           y                      
##                           VARP.SER-v1            VARP.SER-v2     
##                               (1)                    (2)         
## -----------------------------------------------------------------
## v1.l1                      0.273***                              
##                             (0.058)                              
##                                                                  
## v2.l1                      0.023***                              
##                             (0.006)                              
##                                                                  
## v2.l2                      0.027***                              
##                             (0.007)                              
##                                                                  
## const                      0.005***                0.010**       
##                             (0.001)                (0.005)       
##                                                                  
## -----------------------------------------------------------------
## Observations                  254                    254         
## R2                           0.545                  0.016        
## Adjusted R2                  0.537                  0.012        
## Residual Std. Error    0.008 (df = 250)       0.080 (df = 253)   
## F Statistic         74.756*** (df = 4; 250) 4.119** (df = 1; 253)
## =================================================================
## Note:                                 *p<0.1; **p<0.05; ***p<0.01
## 
## =====
## Niraj
## -----
#e)Choleski Decomposition
varp.irfs <- irf(var1, n.ahead=20)
plot(varp.irfs, plot.type="multiple")

varp.fevd <- fevd(var1, n.ahead=60)
varp.fevd[[1]][c(1,4,8,12,20,40,60),]
##             v1        v2
## [1,] 1.0000000 0.0000000
## [2,] 0.8607464 0.1392536
## [3,] 0.8591922 0.1408078
## [4,] 0.8591882 0.1408118
## [5,] 0.8591882 0.1408118
## [6,] 0.8591882 0.1408118
## [7,] 0.8591882 0.1408118
varp.fevd[[2]][c(1,4,8,12,20,40,60),]
##              v1        v2
## [1,] 0.01847382 0.9815262
## [2,] 0.02623100 0.9737690
## [3,] 0.02642786 0.9735721
## [4,] 0.02642813 0.9735719
## [5,] 0.02642813 0.9735719
## [6,] 0.02642813 0.9735719
## [7,] 0.02642813 0.9735719
plot(varp.fevd)

v.Q1 <- cbind(v2, v1)
v.Q1 <- window(v.Q1, start="1951 Q1", end="2014 Q4")
Var1.ord2 <- VAR(v.Q1, p=2, type="const")
varp.irfs <- irf(Var1.ord2, n.ahead=20)
plot(varp.irfs, plot.type="multiple")

varp.fevd <- fevd(Var1.ord2, n.ahead=60)
varp.fevd[[1]][c(1,4,8,12,20,40,60),]
##             v2          v1
## [1,] 1.0000000 0.000000000
## [2,] 0.9935239 0.006476147
## [3,] 0.9934082 0.006591832
## [4,] 0.9934079 0.006592058
## [5,] 0.9934079 0.006592058
## [6,] 0.9934079 0.006592058
## [7,] 0.9934079 0.006592058
varp.fevd[[2]][c(1,4,8,12,20.40,60),]
##              v2        v1
## [1,] 0.01847382 0.9815262
## [2,] 0.18059627 0.8194037
## [3,] 0.18207471 0.8179253
## [4,] 0.18207906 0.8179209
## [5,] 0.18207906 0.8179209
## [6,] 0.18207906 0.8179209
plot(varp.fevd)

There are complete differences in the figures(the extent of v1 and v2). This shift says that by reversing the path of variables, the path of description forecast error variance of each variable by exogenous shocks to other variable is affected.

#Question 2

The objectives of the problem are to make us;

  1. Test the given series for the presence of unit root using KPSS test, ADF or ERS test.

  2. Estimate bivariate reduced form VAR.

  3. Use Blanchard and Quah method to get SVAR.

  4. Plot IRFS and FEVD for the SVAR.

Source of Data: Quandle

# (a) Testing the Given Data Using KPSS and ADF test for unit root.
library(forecast)
## Warning: package 'forecast' was built under R version 3.2.4
## Loading required package: timeDate
## This is forecast 7.0
library(tseries)
## Warning: package 'tseries' was built under R version 3.2.4
library(boxr)
## Warning: package 'boxr' was built under R version 3.2.4
## Welcome to boxr 0.3.2!
## Bug reports: https://github.com/brendan-R/boxr/issues
## 
## See vignette('boxr') for a short guide on connecting your box.com account to R.
Proindex <- Quandl("FRED/INDPRO",api_key="T8gDpM8iFjXR9pfbXBmx",type="zoo")
Conindex <- Quandl("FRED/CPIAUCSL",api_key="T8gDpM8iFjXR9pfbXBmx",type="zoo")
lnProindex <- log(Proindex)
lnConindex <- log(Conindex)
adf.test(lnProindex)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  lnProindex
## Dickey-Fuller = -2.7713, Lag order = 10, p-value = 0.2518
## alternative hypothesis: stationary
adf.test(lnConindex)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  lnConindex
## Dickey-Fuller = -1.2868, Lag order = 9, p-value = 0.8802
## alternative hypothesis: stationary
kpss.test(lnProindex)
## Warning in kpss.test(lnProindex): p-value smaller than printed p-value
## 
##  KPSS Test for Level Stationarity
## 
## data:  lnProindex
## KPSS Level = 14.321, Truncation lag parameter = 7, p-value = 0.01
kpss.test(lnConindex)
## Warning in kpss.test(lnConindex): p-value smaller than printed p-value
## 
##  KPSS Test for Level Stationarity
## 
## data:  lnConindex
## KPSS Level = 11.974, Truncation lag parameter = 6, p-value = 0.01
# Both KPSS and ADF test show that the data aren't stationary. The data have unit root. Let's difference the data to check whether data become stationary.
dlnProindex <- diff(lnProindex)
dlnConindex <- diff(lnConindex)
adf.test(dlnProindex)
## Warning in adf.test(dlnProindex): p-value smaller than printed p-value
## 
##  Augmented Dickey-Fuller Test
## 
## data:  dlnProindex
## Dickey-Fuller = -8.9515, Lag order = 10, p-value = 0.01
## alternative hypothesis: stationary
adf.test(dlnConindex)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  dlnConindex
## Dickey-Fuller = -3.9607, Lag order = 9, p-value = 0.01096
## alternative hypothesis: stationary
kpss.test(dlnProindex)
## Warning in kpss.test(dlnProindex): p-value greater than printed p-value
## 
##  KPSS Test for Level Stationarity
## 
## data:  dlnProindex
## KPSS Level = 0.096697, Truncation lag parameter = 7, p-value = 0.1
kpss.test(dlnConindex)
## Warning in kpss.test(dlnConindex): p-value smaller than printed p-value
## 
##  KPSS Test for Level Stationarity
## 
## data:  dlnConindex
## KPSS Level = 1.0244, Truncation lag parameter = 6, p-value = 0.01
#The result of ADF and KPSS test show that diffrenced data are stationary.
plot(dlnProindex, xlab="Y", ylab="", main="")

plot(dlnConindex,xlab="",ylab="",main="")

#(b):Estimating Bivariate Reduced Form of VAR
v1 <- cbind(dlnProindex, dlnConindex)
v1 <- na.trim(v1) 
VARselect(v1, lag.max = 24, type = "const")
## $selection
## AIC(n)  HQ(n)  SC(n) FPE(n) 
##     15     12      2     15 
## 
## $criteria
##                    1             2             3             4
## AIC(n) -2.134894e+01 -2.139737e+01 -2.140786e+01 -2.142159e+01
## HQ(n)  -2.133551e+01 -2.137500e+01 -2.137653e+01 -2.138131e+01
## SC(n)  -2.131398e+01 -2.133910e+01 -2.132628e+01 -2.131670e+01
## FPE(n)  5.349010e-10  5.096107e-10  5.042929e-10  4.974185e-10
##                    5             6             7             8
## AIC(n) -2.143482e+01 -2.144470e+01 -2.144848e+01 -2.145088e+01
## HQ(n)  -2.138559e+01 -2.138651e+01 -2.138135e+01 -2.137479e+01
## SC(n)  -2.130663e+01 -2.129319e+01 -2.127367e+01 -2.125276e+01
## FPE(n)  4.908800e-10  4.860589e-10  4.842238e-10  4.830656e-10
##                    9            10            11            12
## AIC(n) -2.145710e+01 -2.146746e+01 -2.146412e+01 -2.151244e+01
## HQ(n)  -2.137207e+01 -2.137347e+01 -2.136118e+01 -2.140055e+01
## SC(n)  -2.123567e+01 -2.122272e+01 -2.119607e+01 -2.122109e+01
## FPE(n)  4.800709e-10  4.751286e-10  4.767202e-10  4.542362e-10
##                   13            14            15            16
## AIC(n) -2.150763e+01 -2.150834e+01 -2.151505e+01 -2.150901e+01
## HQ(n)  -2.138679e+01 -2.137855e+01 -2.137631e+01 -2.136131e+01
## SC(n)  -2.119297e+01 -2.117037e+01 -2.115377e+01 -2.112442e+01
## FPE(n)  4.564320e-10  4.561123e-10  4.530691e-10  4.558232e-10
##                   17            18            19            20
## AIC(n) -2.150471e+01 -2.149987e+01 -2.150483e+01 -2.149830e+01
## HQ(n)  -2.134806e+01 -2.133426e+01 -2.133028e+01 -2.131479e+01
## SC(n)  -2.109681e+01 -2.106866e+01 -2.105031e+01 -2.102047e+01
## FPE(n)  4.577955e-10  4.600267e-10  4.577593e-10  4.607713e-10
##                   21            22            23            24
## AIC(n) -2.148921e+01 -2.148050e+01 -2.148168e+01 -2.150155e+01
## HQ(n)  -2.129676e+01 -2.127909e+01 -2.127132e+01 -2.128224e+01
## SC(n)  -2.098808e+01 -2.095606e+01 -2.093393e+01 -2.093049e+01
## FPE(n)  4.649882e-10  4.690717e-10  4.685317e-10  4.593307e-10
#The table above shows that AIC value is minimum at lag 15. Therefore, we will use that lag for further anlaysis.
varv <- VAR(v1, lag.max = 15, ic="AIC", type="const")
varv
## 
## VAR Estimation Results:
## ======================= 
## 
## Estimated coefficients for equation dlnProindex: 
## ================================================ 
## Call:
## dlnProindex = dlnProindex.l1 + dlnConindex.l1 + dlnProindex.l2 + dlnConindex.l2 + dlnProindex.l3 + dlnConindex.l3 + dlnProindex.l4 + dlnConindex.l4 + dlnProindex.l5 + dlnConindex.l5 + dlnProindex.l6 + dlnConindex.l6 + dlnProindex.l7 + dlnConindex.l7 + dlnProindex.l8 + dlnConindex.l8 + dlnProindex.l9 + dlnConindex.l9 + dlnProindex.l10 + dlnConindex.l10 + dlnProindex.l11 + dlnConindex.l11 + dlnProindex.l12 + dlnConindex.l12 + const 
## 
##  dlnProindex.l1  dlnConindex.l1  dlnProindex.l2  dlnConindex.l2 
##     0.304273343     0.234243097     0.084518945    -0.059361296 
##  dlnProindex.l3  dlnConindex.l3  dlnProindex.l4  dlnConindex.l4 
##     0.081635323     0.028560277     0.042678149    -0.066681041 
##  dlnProindex.l5  dlnConindex.l5  dlnProindex.l6  dlnConindex.l6 
##    -0.080363960    -0.001430117     0.003775864    -0.152389355 
##  dlnProindex.l7  dlnConindex.l7  dlnProindex.l8  dlnConindex.l8 
##     0.008698812    -0.123935243     0.036246354     0.011185041 
##  dlnProindex.l9  dlnConindex.l9 dlnProindex.l10 dlnConindex.l10 
##     0.031803363    -0.011593875    -0.015642748    -0.162405542 
## dlnProindex.l11 dlnConindex.l11 dlnProindex.l12 dlnConindex.l12 
##     0.037850244     0.106091969    -0.191202886    -0.189513857 
##           const 
##     0.002703497 
## 
## 
## Estimated coefficients for equation dlnConindex: 
## ================================================ 
## Call:
## dlnConindex = dlnProindex.l1 + dlnConindex.l1 + dlnProindex.l2 + dlnConindex.l2 + dlnProindex.l3 + dlnConindex.l3 + dlnProindex.l4 + dlnConindex.l4 + dlnProindex.l5 + dlnConindex.l5 + dlnProindex.l6 + dlnConindex.l6 + dlnProindex.l7 + dlnConindex.l7 + dlnProindex.l8 + dlnConindex.l8 + dlnProindex.l9 + dlnConindex.l9 + dlnProindex.l10 + dlnConindex.l10 + dlnProindex.l11 + dlnConindex.l11 + dlnProindex.l12 + dlnConindex.l12 + const 
## 
##  dlnProindex.l1  dlnConindex.l1  dlnProindex.l2  dlnConindex.l2 
##   -0.0049607212    0.4241226620    0.0302072664    0.0470790308 
##  dlnProindex.l3  dlnConindex.l3  dlnProindex.l4  dlnConindex.l4 
##    0.0097594881    0.0365321543   -0.0011144333    0.0485875795 
##  dlnProindex.l5  dlnConindex.l5  dlnProindex.l6  dlnConindex.l6 
##   -0.0120975512    0.0554133925    0.0192185259    0.0003051517 
##  dlnProindex.l7  dlnConindex.l7  dlnProindex.l8  dlnConindex.l8 
##   -0.0016149781    0.1001690712    0.0143655325    0.0230141066 
##  dlnProindex.l9  dlnConindex.l9 dlnProindex.l10 dlnConindex.l10 
##   -0.0156854127    0.0826714199    0.0152335972    0.1255120964 
## dlnProindex.l11 dlnConindex.l11 dlnProindex.l12 dlnConindex.l12 
##    0.0038751973    0.0477895960   -0.0142099143   -0.1596538738 
##           const 
##    0.0003405908
# c) Using Blanchard and Quah Model to estimate SVAR to know the effect of shock on production and consumption index.
svarv <- BQ(varv)
svarv
## 
## SVAR Estimation Results:
## ======================== 
## 
## 
## Estimated contemporaneous impact matrix:
##             dlnProindex dlnConindex
## dlnProindex    0.007058    0.004849
## dlnConindex   -0.001372    0.002110
## 
## Estimated identified long run impact matrix:
##             dlnProindex dlnConindex
## dlnProindex     0.01353     0.00000
## dlnConindex    -0.00469     0.01252
summary(svarv)
## 
## SVAR Estimation Results:
## ======================== 
## 
## Call:
## BQ(x = varv)
## 
## Type: Blanchard-Quah 
## Sample size: 817 
## Log Likelihood: 6460.571 
## 
## Estimated contemporaneous impact matrix:
##             dlnProindex dlnConindex
## dlnProindex    0.007058    0.004849
## dlnConindex   -0.001372    0.002110
## 
## Estimated identified long run impact matrix:
##             dlnProindex dlnConindex
## dlnProindex     0.01353     0.00000
## dlnConindex    -0.00469     0.01252
## 
## Covariance matrix of reduced form residuals (*100):
##             dlnProindex dlnConindex
## dlnProindex   7.333e-03   5.486e-05
## dlnConindex   5.486e-05   6.332e-04
# d)

#From the summary table of svarv, we came to know that one positive deviation technology shcock increases industrial production index by o.007058 and lowers the consumer index by 0.001372.
#Similarly, from the summary table of svarv, we came to know that one negative deviation technology shock increases production index by 0.004849 while there is increase in consumer index by 
#The long run effect of non-technological shock on industrial production shock is 0.000 and single deviation will increase the index by 0.01353.
#The long run effect of non-technological shock on consumer index will be negative and decrease by 0.00469 and single deviation will increase the index by 0.01252.
# e and f)
svarv.irfs <- irf(svarv, n.ahead=30)
plot(svarv.irfs, plot.type="multiple")

irfvc <- irf(svarv, n.ahead = 30, cumulative = TRUE)
summary(irfvc)
##            Length Class  Mode     
## irf        2      -none- list     
## Lower      2      -none- list     
## Upper      2      -none- list     
## response   2      -none- character
## impulse    2      -none- character
## ortho      1      -none- logical  
## cumulative 1      -none- logical  
## runs       1      -none- numeric  
## ci         1      -none- numeric  
## boot       1      -none- logical  
## model      1      -none- character
vindex <- fevd(svarv, n.ahead=60)
summary(vindex)
##             Length Class  Mode   
## dlnProindex 120    -none- numeric
## dlnConindex 120    -none- numeric
plot(vindex)

#There are complete differences in the figures. This shift says that by reversing the path of variables, the path of description forecast error variance of each variable by exogenous shocks to other variable is affected.