HOMEWORK RESEARCH
1 The Johansen Test Cointegration
6 series of int.rate
Check that 6 var are I(1)
\(g=6\) => at maximum, 5 cointegrating relationships
r = number of cointegrating relationships, \(r \leq 5=rank(\Pi)\)
Johansen Test: \(H_0: r=0 \ vs \ H_1: r>0\)
if reject, next test \(H_0: r =1 \ vs \ H_1:r>1\)
r => VECM capturing both short-term & long-term relationship between 6 var.
VAR select => IC => Compare => min IV => best lag k
(\(\begin{cases} AIC => k=2 \\ others => k=2\end{cases}\))
library(readxl)
fred_1_ <- read_excel("C:/Users/AD/Downloads/fred.xls", col_types = c("date", "numeric", "numeric", "numeric", "numeric", "numeric", "numeric"))
View(fred_1_)## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
## Loading required package: sandwich
pca = prcomp(fred[c("GS3M","GS6M","GS1","GS3","GS5","GS10")],scale. = TRUE,retx = TRUE)
summary(pca)## Importance of components:
## PC1 PC2 PC3 PC4 PC5 PC6
## Standard deviation 2.4278 0.31481 0.07205 0.03745 0.01418 0.009422
## Proportion of Variance 0.9823 0.01652 0.00087 0.00023 0.00003 0.000010
## Cumulative Proportion 0.9823 0.99885 0.99972 0.99995 0.99999 1.000000
##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression drift
##
##
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + z.diff.lag)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.26740 -0.06143 -0.01215 0.10993 0.74972
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.036205 0.018916 1.914 0.056279 .
## z.lag.1 -0.013851 0.003747 -3.696 0.000247 ***
## z.diff.lag 0.380762 0.042217 9.019 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.2447 on 432 degrees of freedom
## Multiple R-squared: 0.1864, Adjusted R-squared: 0.1826
## F-statistic: 49.47 on 2 and 432 DF, p-value: < 2.2e-16
##
##
## Value of test-statistic is: -3.6965 8.0649
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau2 -3.44 -2.87 -2.57
## phi1 6.47 4.61 3.79
##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression drift
##
##
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + z.diff.lag)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.79563 -0.06997 -0.01655 0.10891 1.04603
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.035953 0.019273 1.865 0.062799 .
## z.lag.1 -0.013235 0.003673 -3.603 0.000351 ***
## z.diff.lag 0.375945 0.043140 8.715 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.247 on 432 degrees of freedom
## Multiple R-squared: 0.1788, Adjusted R-squared: 0.175
## F-statistic: 47.03 on 2 and 432 DF, p-value: < 2.2e-16
##
##
## Value of test-statistic is: -3.603 7.7217
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau2 -3.44 -2.87 -2.57
## phi1 6.47 4.61 3.79
##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression drift
##
##
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + z.diff.lag)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.34854 -0.09643 -0.01473 0.11014 1.11534
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.034388 0.019639 1.751 0.08065 .
## z.lag.1 -0.011941 0.003626 -3.293 0.00107 **
## z.diff.lag 0.406935 0.043166 9.427 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.2479 on 432 degrees of freedom
## Multiple R-squared: 0.1958, Adjusted R-squared: 0.1921
## F-statistic: 52.6 on 2 and 432 DF, p-value: < 2.2e-16
##
##
## Value of test-statistic is: -3.2934 6.4296
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau2 -3.44 -2.87 -2.57
## phi1 6.47 4.61 3.79
##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression drift
##
##
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + z.diff.lag)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.08497 -0.15514 -0.00325 0.14397 0.98517
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.038535 0.022683 1.699 0.09006 .
## z.lag.1 -0.011286 0.003831 -2.946 0.00339 **
## z.diff.lag 0.386096 0.043875 8.800 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.2643 on 432 degrees of freedom
## Multiple R-squared: 0.1719, Adjusted R-squared: 0.1681
## F-statistic: 44.85 on 2 and 432 DF, p-value: < 2.2e-16
##
##
## Value of test-statistic is: -2.9459 5.206
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau2 -3.44 -2.87 -2.57
## phi1 6.47 4.61 3.79
##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression drift
##
##
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + z.diff.lag)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.08009 -0.16054 -0.01031 0.16117 0.88271
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.042109 0.024377 1.727 0.0848 .
## z.lag.1 -0.011118 0.003949 -2.815 0.0051 **
## z.diff.lag 0.367756 0.044284 8.305 1.3e-15 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.2616 on 432 degrees of freedom
## Multiple R-squared: 0.156, Adjusted R-squared: 0.1521
## F-statistic: 39.93 on 2 and 432 DF, p-value: < 2.2e-16
##
##
## Value of test-statistic is: -2.8153 4.8354
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau2 -3.44 -2.87 -2.57
## phi1 6.47 4.61 3.79
##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression drift
##
##
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + z.diff.lag)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.10461 -0.15430 -0.01407 0.16035 0.86687
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.047832 0.026379 1.813 0.07048 .
## z.lag.1 -0.011259 0.004057 -2.775 0.00575 **
## z.diff.lag 0.325390 0.045049 7.223 2.31e-12 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.249 on 432 degrees of freedom
## Multiple R-squared: 0.126, Adjusted R-squared: 0.122
## F-statistic: 31.14 on 2 and 432 DF, p-value: 2.326e-13
##
##
## Value of test-statistic is: -2.7755 4.8994
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau2 -3.44 -2.87 -2.57
## phi1 6.47 4.61 3.79
par(lwd=2,cex.axis = 2)
plot(fred$Date,fred$GS3M,type="l",xlab="",ylab="")
lines(fred$Date,fred$GS6M,col="red")
lines(fred$Date,fred$GS1,col="blue")
lines(fred$Date,fred$GS3,col="brown")
lines(fred$Date,fred$GS5,col="orange")
lines(fred$Date,fred$GS10,col="darkgreen")## Loading required package: lmtest
## $selection
## AIC(n) HQ(n) SC(n) FPE(n)
## 2 2 2 2
##
## $criteria
## 1 2 3 4 5
## AIC(n) -3.048588e+01 -3.088381e+01 -3.087091e+01 -3.087216e+01 -3.082098e+01
## HQ(n) -3.032768e+01 -3.059002e+01 -3.044151e+01 -3.030717e+01 -3.012039e+01
## SC(n) -3.008544e+01 -3.014014e+01 -2.978399e+01 -2.944201e+01 -2.904759e+01
## FPE(n) 5.756508e-14 3.867052e-14 3.918238e-14 3.915114e-14 4.123784e-14
## 6 7 8 9 10
## AIC(n) -3.083823e+01 -3.081106e+01 -3.081602e+01 -3.074647e+01 -3.070735e+01
## HQ(n) -3.000205e+01 -2.983928e+01 -2.970863e+01 -2.950349e+01 -2.932877e+01
## SC(n) -2.872161e+01 -2.835121e+01 -2.801292e+01 -2.760014e+01 -2.721778e+01
## FPE(n) 4.057676e-14 4.175760e-14 4.163494e-14 4.474874e-14 4.668409e-14
## 11 12
## AIC(n) -3.065424e+01 -3.058976e+01
## HQ(n) -2.914007e+01 -2.893998e+01
## SC(n) -2.682144e+01 -2.641372e+01
## FPE(n) 4.942441e-14 5.296642e-14
We see that the series generally follow a linear downward trend, though some series show stronger intertemporal variation, with large drops, than other series.
Additionally, while all series seem to be related in some way, we find that the plots of some rates resemble each other more strictly than others.
##
## ######################
## # Johansen-Procedure #
## ######################
##
## Test type: trace statistic , without linear trend and constant in cointegration
##
## Eigenvalues (lambda):
## [1] 1.933608e-01 1.441940e-01 1.112046e-01 4.191212e-02 1.951328e-02
## [6] 1.837159e-02 -6.011223e-17
##
## Values of teststatistic and critical values of test:
##
## test 10pct 5pct 1pct
## r <= 5 | 8.07 7.52 9.24 12.97
## r <= 4 | 16.64 17.85 19.96 24.60
## r <= 3 | 35.26 32.00 34.91 41.07
## r <= 2 | 86.54 49.65 53.12 60.16
## r <= 1 | 154.28 71.86 76.07 84.45
## r = 0 | 247.75 97.18 102.14 111.01
##
## Eigenvectors, normalised to first column:
## (These are the cointegration relations)
##
## GS3M.l2 GS6M.l2 GS1.l2 GS3.l2 GS5.l2 GS10.l2
## GS3M.l2 1.0000000 1.0000000 1.0000000 1.00000 1.0000000 1.0000000
## GS6M.l2 -1.8361728 -1.7240301 -7.8260887 -45.44358 -2.2414315 -2.1083618
## GS1.l2 0.6584909 1.5591332 10.3520558 64.84908 1.0119005 0.4455494
## GS3.l2 0.7935402 -2.0124537 -9.3559469 36.99190 0.9399850 0.6478099
## GS5.l2 -0.7572572 1.4945981 8.5581204 -111.48938 -1.0083630 -7.7888536
## GS10.l2 0.1275615 -0.2493571 -2.7878414 55.56632 0.4129490 8.1180175
## constant 0.1581499 -0.1180595 0.5424579 -9.32844 -0.5161628 -5.7936204
## constant
## GS3M.l2 1.0000000
## GS6M.l2 0.7974764
## GS1.l2 -2.7026864
## GS3.l2 3.1335814
## GS5.l2 -11.5201333
## GS10.l2 11.7683970
## constant -28.8343237
##
## Weights W:
## (This is the loading matrix)
##
## GS3M.l2 GS6M.l2 GS1.l2 GS3.l2 GS5.l2
## GS3M.d 0.4401418 -0.27515704 0.03139674 0.0004933753 -0.04251249
## GS6M.d 0.6134722 -0.12926923 0.01290303 0.0000976568 -0.03596756
## GS1.d 0.5562986 -0.04534895 -0.01178610 -0.0001540930 -0.04416737
## GS3.d 0.4869795 0.16241326 -0.01436364 0.0006761659 -0.05816293
## GS5.d 0.5302487 0.18077756 -0.02830696 0.0011619122 -0.05582945
## GS10.d 0.5536302 0.18370135 -0.02705497 0.0006235189 -0.05394235
## GS10.l2 constant
## GS3M.d 0.0042441020 1.645681e-16
## GS6M.d 0.0053450249 3.471301e-16
## GS1.d 0.0059033018 3.844782e-16
## GS3.d 0.0046972595 6.173475e-16
## GS5.d 0.0025825107 7.030048e-16
## GS10.d -0.0001778005 5.828148e-16
- Johansen test \(=> Test \ H_o : r=0 \ vs \ H_1: r>0 \ \scriptsize(test \ right \ tail)\\=> TS = 247 > 102 \ \ \small(CV \ at \ 5 \%) \\ => reject \ H_0 \\ => Test \ H_0: r=1 \ vs \ H_1 :r>1 \\ =>TS =154 >CV=76 \\=> reject \ H_0 \\ => Test \ H_0:r=2 \ vs \ H_1: r>2\\=>TS=86>CV=53 => reject \ H_0\\ => Test \ H_0: r = 3 \ vs \ H_1 : r > 3 \\ \ \ \ \ using \ TS= 35 < CV =41 \ at \ 1\% \ \ significant \ level \\ => not \ reject \ H_0 => take \ r=3\)
vecm = ca.jo(fred[c("GS3M","GS6M","GS1","GS3","GS5","GS10")],K=2,ecdet = "const",type = "trace")
cajorls(vecm,r=3)## $rlm
##
## Call:
## lm(formula = substitute(form1), data = data.mat)
##
## Coefficients:
## GS3M.d GS6M.d GS1.d GS3.d GS5.d
## ect1 0.1963815 0.4971060 0.4991636 0.6350292 0.6827193
## ect2 -0.5795111 -1.0045571 -0.8510384 -1.0617728 -1.0637614
## ect3 0.1858437 0.3359907 0.1736022 0.4252023 0.3379851
## GS3M.dl1 0.8046578 1.0052603 0.7937785 0.7297938 0.7851838
## GS6M.dl1 -1.3002259 -1.7480493 -1.3158642 -1.4676407 -1.4515766
## GS1.dl1 0.7261699 1.0482154 0.7538492 0.9610662 0.7470956
## GS3.dl1 0.3414507 -0.0154097 -0.0679247 -0.2322351 -0.0695104
## GS5.dl1 -0.1705721 0.2690776 0.4427480 0.5318636 0.3428756
## GS10.dl1 -0.0816765 -0.1924225 -0.2043656 -0.1335948 -0.0008461
## GS10.d
## ect1 0.7102766
## ect2 -1.1215328
## ect3 0.3709008
## GS3M.dl1 0.7296653
## GS6M.dl1 -1.3219279
## GS1.dl1 0.6686458
## GS3.dl1 -0.3048205
## GS5.dl1 0.4572949
## GS10.dl1 0.0573718
##
##
## $beta
## ect1 ect2 ect3
## GS3M.l2 1.000000e+00 -2.220446e-16 -3.122502e-17
## GS6M.l2 0.000000e+00 1.000000e+00 5.551115e-17
## GS1.l2 -4.440892e-16 -2.220446e-16 1.000000e+00
## GS3.l2 -2.499094e+00 -2.786098e+00 -2.768639e+00
## GS5.l2 1.573232e+00 2.073284e+00 2.242124e+00
## GS10.l2 9.893932e-02 -1.585894e-01 -3.987532e-01
## constant -5.346689e-01 -4.664695e-01 -2.485984e-01
Run VECM with \(r=3\) (explain?)
3 cointegration relationships with \(y_1 \rightarrow 3M\\y_2 \rightarrow 6M \\ y_3 \rightarrow 1Y \\ y_4 \rightarrow 3Y\\y_5\rightarrow 5Y\\ y_6\rightarrow 10Y\)
\(ect1 = y_1 +0\times y_2 +0\times y_3-2.49y_4 +1.57y_5+9.8\times10^{-2}y_6-0.5\ \\ \ \ \ \ \ \ \ (=0\ in \ the \ longrun)\\ similarly\ for \\ect2 = 0\times y_1 +y_2+0\times y_3-2.79y_4+2.07y_5-0.159y_6 -0.66\\ect3= 0\times y_1+0\times y_2+y_3-2.77y_4+2.24y_5-0.4y_6-0.25\)
VECM => 6 equations
\(\Delta y_{1,t}=0.19(ect1)_{t-2} - 0.57(ect2)_{t-2} +0.18(ect3)_{t-2}+0.8\Delta y_{1,t-1} -1.3\Delta y_{2,t-1} \\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ +0.7\Delta y_{3,t-1}+0.3\Delta y_{4,t-1} -0.17\Delta y_{5,t-1}-0.08\Delta y_{6,t-1}\)