Q2).
In this questiestion name industrial production as “IPI” and Consumer Price Index as “CPI” First install all the software that we need to solve this problem
library("Quandl")
library("vars")
library("gdata")
library("stargazer")
library("tseries")
Downloard the two series of data
IPI<-Quandl("FRED/INDPRO", type="zoo")
CPI<-Quandl("FRED/CPIAUCSL", type="zoo")
Transform and rename variables
y1t <- log(IPI)
y2t <- log(CPI)
dy1t <- diff(y1t)
dy2t <- diff(y2t)
Plot the variables and difference of the series
par(mfrow=c(2,2))
plot(y1t,xlab="Year", ylab="Log(IPI)")
plot(y2t,xlab="Year", ylab="Log(CPI)")
plot(dy1t,xlab="Year", ylab="Diff(LIPI)")
plot(dy2t,xlab="Year", ylab="Diff(LCPI)")
…………………………………………………………………………………………………………………………………………………………………………………………….
(a). Unit root test to test for the stationarity
adf.test(y1t)
##
## Augmented Dickey-Fuller Test
##
## data: y1t
## Dickey-Fuller = -2.7713, Lag order = 10, p-value = 0.2518
## alternative hypothesis: stationary
adf.test(y2t)
##
## Augmented Dickey-Fuller Test
##
## data: y2t
## Dickey-Fuller = -1.2868, Lag order = 9, p-value = 0.8802
## alternative hypothesis: stationary
adf.test(dy1t)
## Warning in adf.test(dy1t): p-value smaller than printed p-value
##
## Augmented Dickey-Fuller Test
##
## data: dy1t
## Dickey-Fuller = -8.9515, Lag order = 10, p-value = 0.01
## alternative hypothesis: stationary
adf.test(dy2t)
##
## Augmented Dickey-Fuller Test
##
## data: dy2t
## Dickey-Fuller = -3.9607, Lag order = 9, p-value = 0.01096
## alternative hypothesis: stationary
ADF test indivate that the both variables are nonstationary at log levels. However, first difference of the series are statioanry. Note: H0: There is a unit root
…………………………………………………………………………………………….. ……………………………………………………………………………………………..
(b).
In this part we estimate the bivariate reduced form VAR. First combinethe two series and sellectoptimal lag length
library("vars")
y <- cbind(dy1t, dy2t)
y <- na.trim(y)
y<-sweep(y,2,apply(y,2,mean))
VARselect(y,lag.max=8)
## $selection
## AIC(n) HQ(n) SC(n) FPE(n)
## 7 6 2 7
##
## $criteria
## 1 2 3 4
## AIC(n) -2.123881e+01 -2.128068e+01 -2.130123e+01 -2.131146e+01
## HQ(n) -2.122560e+01 -2.125867e+01 -2.127041e+01 -2.127183e+01
## SC(n) -2.120439e+01 -2.122331e+01 -2.122091e+01 -2.120818e+01
## FPE(n) 5.971746e-10 5.726866e-10 5.610375e-10 5.553301e-10
## 5 6 7 8
## AIC(n) -2.132000e+01 -2.132956e+01 -2.133296e+01 -2.133237e+01
## HQ(n) -2.127157e+01 -2.127232e+01 -2.126692e+01 -2.125752e+01
## SC(n) -2.119377e+01 -2.118038e+01 -2.116083e+01 -2.113729e+01
## FPE(n) 5.506083e-10 5.453727e-10 5.435220e-10 5.438459e-10
according to the lagselection criteria, maximum lag leng is 7. Then the model VAR(7)
var<-VAR(y,p=7, type="const")
summary(var)
##
## VAR Estimation Results:
## =========================
## Endogenous variables: dy1t, dy2t
## Deterministic variables: const
## Sample size: 822
## Log Likelihood: 6452.474
## Roots of the characteristic polynomial:
## 0.9028 0.7865 0.7371 0.7371 0.7223 0.7223 0.6597 0.6597 0.6512 0.6512 0.6193 0.6193 0.4736 0.4736
## Call:
## VAR(y = y, p = 7, type = "const")
##
##
## Estimation results for equation dy1t:
## =====================================
## dy1t = dy1t.l1 + dy2t.l1 + dy1t.l2 + dy2t.l2 + dy1t.l3 + dy2t.l3 + dy1t.l4 + dy2t.l4 + dy1t.l5 + dy2t.l5 + dy1t.l6 + dy2t.l6 + dy1t.l7 + dy2t.l7 + const
##
## Estimate Std. Error t value Pr(>|t|)
## dy1t.l1 3.119e-01 3.519e-02 8.865 < 2e-16 ***
## dy2t.l1 2.182e-01 1.141e-01 1.911 0.05632 .
## dy1t.l2 9.524e-02 3.679e-02 2.589 0.00981 **
## dy2t.l2 -9.303e-02 1.246e-01 -0.747 0.45544
## dy1t.l3 8.096e-02 3.699e-02 2.189 0.02891 *
## dy2t.l3 -6.987e-04 1.243e-01 -0.006 0.99551
## dy1t.l4 4.045e-02 3.706e-02 1.091 0.27538
## dy2t.l4 -1.110e-01 1.239e-01 -0.896 0.37048
## dy1t.l5 -7.732e-02 3.688e-02 -2.097 0.03633 *
## dy2t.l5 -2.493e-02 1.232e-01 -0.202 0.83973
## dy1t.l6 1.333e-02 3.684e-02 0.362 0.71752
## dy2t.l6 -2.069e-01 1.208e-01 -1.712 0.08721 .
## dy1t.l7 2.976e-02 3.509e-02 0.848 0.39661
## dy2t.l7 -1.086e-01 1.116e-01 -0.973 0.33067
## const 8.453e-06 3.036e-04 0.028 0.97779
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## Residual standard error: 0.008703 on 807 degrees of freedom
## Multiple R-Squared: 0.1932, Adjusted R-squared: 0.1792
## F-statistic: 13.8 on 14 and 807 DF, p-value: < 2.2e-16
##
##
## Estimation results for equation dy2t:
## =====================================
## dy2t = dy1t.l1 + dy2t.l1 + dy1t.l2 + dy2t.l2 + dy1t.l3 + dy2t.l3 + dy1t.l4 + dy2t.l4 + dy1t.l5 + dy2t.l5 + dy1t.l6 + dy2t.l6 + dy1t.l7 + dy2t.l7 + const
##
## Estimate Std. Error t value Pr(>|t|)
## dy1t.l1 -5.826e-03 1.081e-02 -0.539 0.58993
## dy2t.l1 4.434e-01 3.506e-02 12.648 < 2e-16 ***
## dy1t.l2 2.907e-02 1.130e-02 2.572 0.01028 *
## dy2t.l2 4.396e-02 3.826e-02 1.149 0.25095
## dy1t.l3 6.764e-03 1.136e-02 0.595 0.55173
## dy2t.l3 6.811e-02 3.816e-02 1.785 0.07464 .
## dy1t.l4 -2.168e-03 1.138e-02 -0.190 0.84897
## dy2t.l4 4.042e-02 3.805e-02 1.062 0.28847
## dy1t.l5 -1.991e-02 1.133e-02 -1.758 0.07912 .
## dy2t.l5 5.481e-02 3.784e-02 1.449 0.14785
## dy1t.l6 2.413e-02 1.131e-02 2.133 0.03323 *
## dy2t.l6 5.981e-02 3.711e-02 1.611 0.10746
## dy1t.l7 3.861e-03 1.077e-02 0.358 0.72017
## dy2t.l7 9.329e-02 3.428e-02 2.722 0.00663 **
## const -2.298e-05 9.323e-05 -0.246 0.80537
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## Residual standard error: 0.002673 on 807 degrees of freedom
## Multiple R-Squared: 0.4078, Adjusted R-squared: 0.3975
## F-statistic: 39.69 on 14 and 807 DF, p-value: < 2.2e-16
##
##
##
## Covariance matrix of residuals:
## dy1t dy2t
## dy1t 7.575e-05 7.511e-07
## dy2t 7.511e-07 7.144e-06
##
## Correlation matrix of residuals:
## dy1t dy2t
## dy1t 1.00000 0.03229
## dy2t 0.03229 1.00000
…………………………………………………………………………………………………………………………………………………………………………………………….
(C). Structral VAR Demand shocks
svar <- BQ(var)
summary(svar)
##
## SVAR Estimation Results:
## ========================
##
## Call:
## BQ(x = var)
##
## Type: Blanchard-Quah
## Sample size: 822
## Log Likelihood: 6437.336
##
## Estimated contemporaneous impact matrix:
## dy1t dy2t
## dy1t 0.007721 0.004017
## dy2t -0.001156 0.002410
##
## Estimated identified long run impact matrix:
## dy1t dy2t
## dy1t 0.01706 0.00000
## dy2t -0.00277 0.01228
##
## Covariance matrix of reduced form residuals (*100):
## dy1t dy2t
## dy1t 7.575e-03 7.511e-05
## dy2t 7.511e-05 7.144e-04
…………………………………………………………………………………………………………………………………………………………………………………………….
(d).
According to the contemporaneous impact matrics, in the first eqoation (industrial production as dependent variable) there is possitive effect from the itself and the possitive effect from industrial production index (both variables consider as growth). However, in the second equation, there is a negative effect from the first variables and possitive effect from the second varible. Here firiable in the first equation is growth of IPI and the first variable in the second equation is growth CPI
However, for the long run effect, there is no long run effect fro the growth of IPI by the growth of CPI. But there is a long run effect for the growth of CPI by growth of IPI.
…………………………………………………………………………………………………………………………………………………………………………………………….
(e).
Impulse response function
virf <- irf(svar, n.ahead=40, cumulative=TRUE)
par(mfcol=c(2,2))
plot(virf, plot.type="single")
according to the IRF,shock to the growth of IPI increse the growth of IPI until the first ten months and then converges to 0.015%. However, this shock has a negative effect on inflation though it is not significant. On the other hand, shock to the inflation, increase the growth of GDP til first six months and decrese gradually to its original level. How ever, there is a significat possitive effect (continous increase) on growth of inflation.
…………………………………………………………………………………………………………………………………………………………………………………………….
(f).
FEVD for the SVAR
vfevd <- fevd(svar, n.ahead=40)
vfevd[[1]][c(1,4,8,40),]
## dy1t dy2t
## [1,] 0.7869807 0.2130193
## [2,] 0.7647388 0.2352612
## [3,] 0.7640897 0.2359103
## [4,] 0.7497064 0.2502936
vfevd[[2]][c(1,4,8,40),]
## dy1t dy2t
## [1,] 0.1871906 0.8128094
## [2,] 0.1771762 0.8228238
## [3,] 0.1639252 0.8360748
## [4,] 0.1455469 0.8544531
Plotinf Variance decomposition
plot(vfevd)
Arount 80% percent of the variance of growth of IPI explaining by it self and variation of groth of CPI explained arround 20% by IPI.
END …………………………………………………………………………………………………………………………………………………………………………………………….