# 9 Multivariate Time Series Models

## 9.1 Table 9.1

``````library(haven)
library(urca)
library(stargazer)
library(dplyr)
rm(list = ls())``````

Spurious regression: OLS involving two independent random walks

``````df <- read_dta("Data/spurious.dta")
summary(OLS <- lm(y ~ x, data=df))``````
``````##
## Call:
## lm(formula = y ~ x, data = df)
##
## Residuals:
##     Min      1Q  Median      3Q     Max
## -6.4625 -2.5223 -0.0414  2.1179  8.2879
##
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)
## (Intercept)  3.90971    0.24618   15.88   <2e-16 ***
## x           -0.44348    0.04733   -9.37   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 3.27 on 198 degrees of freedom
## Multiple R-squared:  0.3072, Adjusted R-squared:  0.3037
## F-statistic:  87.8 on 1 and 198 DF,  p-value: < 2.2e-16``````

## 9.2 Table 9.4

Unit root tests for log price ratio euro zone versus UK

``````df <- read_dta("Data/ppp2.dta")
df\$ratio <- log(df\$cpieuro)-log(df\$cpiuk)

urt <- NULL
for (i in c(1:7, 13, 25, 37)) {
urt=rbind(urt,  c(ur.df(df\$ratio, lag=i-1, type="drift")@testreg\$coefficients[2, 3],
ur.df(df\$ratio, lag=i-1,  type="trend")@testreg\$coefficients[2, 3]))
}
rownames(urt) <- paste0(c(rep("ADF(", 10)),  c(0:6, 12, 24, 36), ")")
colnames(urt) <- c("Without trend", "With trend")
urt``````
``````##         Without trend With trend

## 9.3 Table 9.5

OLS results

``summary(OLS <- lm(log(fxep)  ~  ratio, data=df))``
``````##
## Call:
## lm(formula = log(fxep) ~ ratio, data = df)
##
## Residuals:
##      Min       1Q   Median       3Q      Max
## -0.24561 -0.08619  0.01368  0.06477  0.22179
##
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.344580   0.009013  38.231  < 2e-16 ***
## ratio       1.016570   0.281252   3.614 0.000358 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.1045 on 274 degrees of freedom
## Multiple R-squared:  0.04551,    Adjusted R-squared:  0.04203
## F-statistic: 13.06 on 1 and 274 DF,  p-value: 0.0003581``````

## 9.4 Table 9.6

``````DF=ur.df(OLS\$residuals, lag=0, type="none")@testreg\$coef[1, 3]
ttest``````
``````##             DF    ADF1      ADF2      ADF3      ADF4      ADF5      ADF6
## [1,] -1.500324 -1.4827 -1.436882 -1.486919 -1.638509 -1.531673 -1.401741``````

## 9.5 Table 9.7

OLS results

``summary(OLS2 <- lm(log(fxep)  ~  log(cpieuro) + log(cpiuk),  data=df))``
``````##
## Call:
## lm(formula = log(fxep) ~ log(cpieuro) + log(cpiuk), data = df)
##
## Residuals:
##      Min       1Q   Median       3Q      Max
## -0.24406 -0.08568  0.01416  0.06590  0.22198
##
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)
## (Intercept)    0.3782     0.1893   1.998 0.046703 *
## log(cpieuro)   1.0076     0.2863   3.520 0.000506 ***
## log(cpiuk)    -1.0151     0.2819  -3.601 0.000376 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.1047 on 273 degrees of freedom
## Multiple R-squared:  0.04562,    Adjusted R-squared:  0.03863
## F-statistic: 6.525 on 2 and 273 DF,  p-value: 0.001706``````

## 9.6 Table 9.8

``````DF=ur.df(OLS2\$residuals, lag=0, type="none")@testreg\$coef[1, 3]
ttest``````
``````##             DF      ADF1      ADF2      ADF3      ADF4      ADF5      ADF6
## [1,] -1.511092 -1.493352 -1.445349 -1.493263 -1.643185 -1.537527 -1.408899``````

## 9.7 Table 9.10

Maximum eigenvalue tests for cointegration

``````Y <- cbind(s=df\$fxep, p=df\$cpieuro, pstar=df\$cpiuk)
summary(joci.3 <- ca.jo(log(Y), type="eigen", ecdet="const", K=3))``````
``````##
## ######################
## # Johansen-Procedure #
## ######################
##
## Test type: maximal eigenvalue statistic (lambda max) , without linear trend and constant in cointegration
##
## Eigenvalues (lambda):
## [1]  2.602005e-01  5.538624e-02  1.483851e-02 -1.114583e-16
##
## Values of teststatistic and critical values of test:
##
##           test 10pct  5pct  1pct
## r <= 2 |  4.08  7.52  9.24 12.97
## r <= 1 | 15.56 13.75 15.67 20.20
## r = 0  | 82.28 19.77 22.00 26.81
##
## Eigenvectors, normalised to first column:
## (These are the cointegration relations)
##
##                s.l3      p.l3  pstar.l3  constant
## s.l3       1.000000  1.000000  1.000000  1.000000
## p.l3      -8.945951 -4.492447  6.539565 -0.421128
## pstar.l3  11.432758  4.644277 -6.000746 -1.109746
## constant -13.013509 -1.081750 -2.593314  6.492272
##
## Weights W:
##
##                 s.l3          p.l3      pstar.l3      constant
## s.d      0.001815465  0.0004296142 -0.0123638920  3.918377e-15
## p.d     -0.001592238  0.0007878685 -0.0002595288 -9.948096e-16
## pstar.d -0.001690273 -0.0057697130 -0.0002100942 -1.733606e-15``````

## 9.8 Table 9.11

Maximum eigenvalue tests for cointegration

``summary(joci.13 <- ca.jo(log(Y),  type="eigen", ecdet="const", K=13))``
``````##
## ######################
## # Johansen-Procedure #
## ######################
##
## Test type: maximal eigenvalue statistic (lambda max) , without linear trend and constant in cointegration
##
## Eigenvalues (lambda):
## [1] 6.240329e-02 3.594226e-02 1.666837e-02 1.387779e-17
##
## Values of teststatistic and critical values of test:
##
##           test 10pct  5pct  1pct
## r <= 2 |  4.42  7.52  9.24 12.97
## r <= 1 |  9.63 13.75 15.67 20.20
## r = 0  | 16.95 19.77 22.00 26.81
##
## Eigenvectors, normalised to first column:
## (These are the cointegration relations)
##
##               s.l13       p.l13  pstar.l13  constant
## s.l13      1.000000   1.0000000  1.0000000  1.000000
## p.l13     -9.680770   0.9251439  0.7601737 -1.803155
## pstar.l13 10.186738   2.7358162 -0.8346392 -6.111982
## constant  -3.019162 -18.6722070  0.1053253 35.439004
##
## Weights W:
##
##                s.l13         p.l13     pstar.l13      constant
## s.d      0.006495869 -0.0051660978 -1.612575e-02  6.337177e-16
## p.d     -0.000779766 -0.0004467662  1.787728e-03 -3.986908e-16
## pstar.d -0.004050001 -0.0002400787  9.250164e-05 -1.298598e-15``````

## 9.9 Table 9.12

Johansen estimation results

``joci.13@V``
``````##               s.l13       p.l13  pstar.l13  constant
## s.l13      1.000000   1.0000000  1.0000000  1.000000
## p.l13     -9.680770   0.9251439  0.7601737 -1.803155
## pstar.l13 10.186738   2.7358162 -0.8346392 -6.111982
## constant  -3.019162 -18.6722070  0.1053253 35.439004``````

## 9.10 Table 9.13

Univariate cointegrating regressions by OLS

``````df <- read_dta("Data/money.dta")
colnames(df)=c("date", "infl", "m", "y", "cpr", "tbr")

summary(MD <- lm(m ~ y+tbr, data=df))``````
``````##
## Call:
## lm(formula = m ~ y + tbr, data = df)
##
## Residuals:
##       Min        1Q    Median        3Q       Max
## -0.141931 -0.036746 -0.001974  0.044776  0.147458
##
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)
## (Intercept)  3.188592   0.122285   26.07   <2e-16 ***
## y            0.422754   0.015903   26.58   <2e-16 ***
## tbr         -0.031172   0.001879  -16.59   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.05769 on 161 degrees of freedom
## Multiple R-squared:  0.815,  Adjusted R-squared:  0.8127
## F-statistic: 354.6 on 2 and 161 DF,  p-value: < 2.2e-16``````
``ur.df(MD\$residuals, lag=6, type="drift")@testreg``
``````##
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + z.diff.lag)
##
## Residuals:
##       Min        1Q    Median        3Q       Max
## -0.118571 -0.008014  0.002469  0.011418  0.069896
##
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.0000664  0.0018236  -0.036  0.97100
## z.lag.1     -0.1302751  0.0411833  -3.163  0.00189 **
## z.diff.lag1  0.3548291  0.0799944   4.436 1.77e-05 ***
## z.diff.lag2 -0.3485983  0.0834526  -4.177 5.01e-05 ***
## z.diff.lag3  0.4370226  0.0846448   5.163 7.66e-07 ***
## z.diff.lag4 -0.1496378  0.0889194  -1.683  0.09450 .
## z.diff.lag5  0.3508476  0.0795820   4.409 1.98e-05 ***
## z.diff.lag6 -0.0910213  0.0828410  -1.099  0.27365
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.02275 on 149 degrees of freedom
## Multiple R-squared:  0.2758, Adjusted R-squared:  0.2418
## F-statistic: 8.106 on 7 and 149 DF,  p-value: 2.419e-08``````
``summary(FE <- lm(infl ~ tbr, data=df))``
``````##
## Call:
## lm(formula = infl ~ tbr, data = df)
##
## Residuals:
##     Min      1Q  Median      3Q     Max
## -3.8222 -1.4433 -0.2281  1.1153  6.9737
##
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)
## (Intercept)  1.15799    0.33322   3.475 0.000655 ***
## tbr          0.55827    0.05278  10.578  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.98 on 162 degrees of freedom
## Multiple R-squared:  0.4085, Adjusted R-squared:  0.4049
## F-statistic: 111.9 on 1 and 162 DF,  p-value: < 2.2e-16``````
``ur.df(FE\$residuals, lag=6, type="drift")@testreg``
``````##
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + z.diff.lag)
##
## Residuals:
##     Min      1Q  Median      3Q     Max
## -4.2310 -0.8866 -0.0235  0.7727  4.2806
##
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.05534    0.11477  -0.482  0.63036
## z.lag.1     -0.13929    0.07270  -1.916  0.05729 .
## z.diff.lag1 -0.60433    0.09990  -6.049 1.12e-08 ***
## z.diff.lag2 -0.38192    0.11005  -3.471  0.00068 ***
## z.diff.lag3 -0.26250    0.11221  -2.339  0.02065 *
## z.diff.lag4 -0.09450    0.10831  -0.872  0.38435
## z.diff.lag5 -0.04630    0.10043  -0.461  0.64547
## z.diff.lag6 -0.05611    0.08079  -0.695  0.48840
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.437 on 149 degrees of freedom
## Multiple R-squared:  0.3607, Adjusted R-squared:  0.3307
## F-statistic: 12.01 on 7 and 149 DF,  p-value: 4.236e-12``````
``summary(RP <- lm(cpr ~ tbr, data=df))``
``````##
## Call:
## lm(formula = cpr ~ tbr, data = df)
##
## Residuals:
##      Min       1Q   Median       3Q      Max
## -0.85555 -0.23869 -0.07406  0.12861  2.47128
##
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)
## (Intercept)  0.46126    0.06533    7.06 4.63e-11 ***
## tbr          1.03795    0.01035  100.31  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.3882 on 162 degrees of freedom
## Multiple R-squared:  0.9842, Adjusted R-squared:  0.9841
## F-statistic: 1.006e+04 on 1 and 162 DF,  p-value: < 2.2e-16``````
``ur.df(RP\$residuals, lag=6, type="drift")@testreg``
``````##
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + z.diff.lag)
##
## Residuals:
##      Min       1Q   Median       3Q      Max
## -0.74347 -0.14938 -0.04633  0.13622  1.48284
##
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)
## (Intercept)  0.0001915  0.0232992   0.008   0.9935
## z.lag.1     -0.3855820  0.0953090  -4.046 8.35e-05 ***
## z.diff.lag1  0.1697979  0.1007128   1.686   0.0939 .
## z.diff.lag2 -0.1257426  0.0979529  -1.284   0.2012
## z.diff.lag3  0.1154392  0.0956164   1.207   0.2292
## z.diff.lag4  0.0852857  0.0932637   0.914   0.3620
## z.diff.lag5  0.0535072  0.0832304   0.643   0.5213
## z.diff.lag6 -0.0878361  0.0813895  -1.079   0.2822
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.2919 on 149 degrees of freedom
## Multiple R-squared:  0.2546, Adjusted R-squared:  0.2195
## F-statistic: 7.269 on 7 and 149 DF,  p-value: 1.721e-07``````

## 9.11 Figure 9.1

Residuals of money demand regression.

``````plot(MD\$residuals, type="l", xlab="", ylab="", col="blue", ylim=c(-0.15, 0.15),  sub="Figure 9.1 Residuals of money demand regression.", cex.sub=.8)
abline(h=0, lty=2)``````

## 9.12 Figure 9.2

Residuals of Fisher regression.

``````plot(FE\$residuals, type="l", xlab="", ylab="", col="brown", ylim=c(-4, 8), sub="Figure 9.2 Residuals of Fisher regression.", cex.sub=.8)
abline(h=0, lty=2)``````

## 9.13 Figure 9.3

``````plot(RP\$residuals, type="l", xlab="", ylab="", col="orange", ylim=c(-1, 3), sub="Figure 9.3 Residuals of risk premium regression.", cex.sub=.8)
abline(h=0, lty=2)``````

## 9.14 Table 9.14

Trace and maximum eigenvalue tests for cointegration

``````trace.5 = ca.jo(df[, -1], type="trace", ecdet="const", K=5)
summary(trace.5)``````
``````##
## ######################
## # Johansen-Procedure #
## ######################
##
## Test type: trace statistic , without linear trend and constant in cointegration
##
## Eigenvalues (lambda):
## [1] 2.458156e-01 1.731705e-01 1.027893e-01 5.100304e-02 2.239700e-02
## [6] 5.575823e-16
##
## Values of teststatistic and critical values of test:
##
##            test 10pct  5pct  1pct
## r <= 4 |   3.60  7.52  9.24 12.97
## r <= 3 |  11.93 17.85 19.96 24.60
## r <= 2 |  29.17 32.00 34.91 41.07
## r <= 1 |  59.41 49.65 53.12 60.16
## r = 0  | 104.26 71.86 76.07 84.45
##
## Eigenvectors, normalised to first column:
## (These are the cointegration relations)
##
##              infl.l5      m.l5         y.l5     cpr.l5      tbr.l5   constant
## infl.l5     1.000000   1.00000    1.0000000  1.0000000   1.0000000   1.000000
## m.l5       36.656697  29.74807   54.0899909  3.8165096  -5.0106647 -51.349675
## y.l5      -15.856453 -18.56765  -30.5983755 -2.5538370   7.1138867   6.304776
## cpr.l5     -2.571899 -34.04671    0.9079543 -1.1598350   0.3472115   1.646984
## tbr.l5      3.638924  36.01204    1.1681748  0.1777462  -1.0667505  -2.343884
## constant -120.335303 -27.47772 -117.5286189 -1.2478775 -24.9127841 275.375048
##
## Weights W:
##
##             infl.l5          m.l5          y.l5        cpr.l5        tbr.l5
## infl.d -0.076905806 -4.476970e-02 -0.0503732918  0.0451856048 -0.0520655925
## m.d    -0.000249533  1.600878e-04 -0.0004854944 -0.0003452946  0.0001517958
## y.d    -0.001449370  7.724998e-05 -0.0001018686  0.0004575570  0.0001025061
## cpr.d   0.064149061  9.989139e-03 -0.0289892535  0.0623279416  0.0026641115
## tbr.d   0.047738044 -1.682065e-04 -0.0294019158  0.0532235550  0.0139059927
##             constant
## infl.d -6.471404e-14
## m.d    -3.077914e-16
## y.d    -6.298405e-16
## cpr.d   1.378946e-14
## tbr.d   1.232139e-15``````
``````trace.6 = ca.jo(df[, -1], type="trace", ecdet="const", K=6)
summary(trace.6)``````
``````##
## ######################
## # Johansen-Procedure #
## ######################
##
## Test type: trace statistic , without linear trend and constant in cointegration
##
## Eigenvalues (lambda):
## [1]  2.690240e-01  1.971095e-01  1.299891e-01  7.253771e-02  1.732417e-02
## [6] -1.882436e-16
##
## Values of teststatistic and critical values of test:
##
##            test 10pct  5pct  1pct
## r <= 4 |   2.76  7.52  9.24 12.97
## r <= 3 |  14.66 17.85 19.96 24.60
## r <= 2 |  36.66 32.00 34.91 41.07
## r <= 1 |  71.35 49.65 53.12 60.16
## r = 0  | 120.86 71.86 76.07 84.45
##
## Eigenvectors, normalised to first column:
## (These are the cointegration relations)
##
##              infl.l6       m.l6        y.l6     cpr.l6      tbr.l6   constant
## infl.l6     1.000000    1.00000    1.000000  1.0000000   1.0000000    1.00000
## m.l6       36.334894  204.19217   57.751754  1.6133149 -10.1762449 -200.70476
## y.l6      -15.962519  -74.54249  -31.016102 -2.8609857   7.2899859  -27.84829
## cpr.l6     -4.676546   98.22571   -3.901578 -0.1247101   0.7361456   28.87986
## tbr.l6      5.764312  -94.35876    6.197234 -0.6761898  -1.3263551  -25.04501
## constant -115.861539 -832.43682 -134.719135 13.3510670   5.0054743 1448.32325
##
## Weights W:
##
##              infl.l6          m.l6          y.l6        cpr.l6        tbr.l6
## infl.d -9.120064e-02  8.038836e-03 -1.090757e-01  0.0438439893 -4.825389e-02
## m.d    -9.171581e-05 -9.180989e-05 -2.395308e-04 -0.0004508571  1.371533e-04
## y.d    -1.475957e-03 -5.898253e-05  4.127615e-05  0.0006668840 -1.867595e-05
## cpr.d   8.931169e-02 -3.201404e-03 -1.888907e-02  0.0863241017 -1.684758e-03
## tbr.d   4.960367e-02 -1.101318e-03 -2.911223e-02  0.0784889361  8.438562e-03
##             constant
## infl.d -1.763205e-14
## m.d    -2.650060e-16
## y.d    -2.364325e-16
## cpr.d  -5.776105e-15
## tbr.d  -8.371206e-15``````
``````eigen.5 = ca.jo(df[, -1], type="eigen", ecdet="const", K=5)
summary(eigen.5)``````
``````##
## ######################
## # Johansen-Procedure #
## ######################
##
## Test type: maximal eigenvalue statistic (lambda max) , without linear trend and constant in cointegration
##
## Eigenvalues (lambda):
## [1] 2.458156e-01 1.731705e-01 1.027893e-01 5.100304e-02 2.239700e-02
## [6] 5.575823e-16
##
## Values of teststatistic and critical values of test:
##
##           test 10pct  5pct  1pct
## r <= 4 |  3.60  7.52  9.24 12.97
## r <= 3 |  8.32 13.75 15.67 20.20
## r <= 2 | 17.25 19.77 22.00 26.81
## r <= 1 | 30.23 25.56 28.14 33.24
## r = 0  | 44.86 31.66 34.40 39.79
##
## Eigenvectors, normalised to first column:
## (These are the cointegration relations)
##
##              infl.l5      m.l5         y.l5     cpr.l5      tbr.l5   constant
## infl.l5     1.000000   1.00000    1.0000000  1.0000000   1.0000000   1.000000
## m.l5       36.656697  29.74807   54.0899909  3.8165096  -5.0106647 -51.349675
## y.l5      -15.856453 -18.56765  -30.5983755 -2.5538370   7.1138867   6.304776
## cpr.l5     -2.571899 -34.04671    0.9079543 -1.1598350   0.3472115   1.646984
## tbr.l5      3.638924  36.01204    1.1681748  0.1777462  -1.0667505  -2.343884
## constant -120.335303 -27.47772 -117.5286189 -1.2478775 -24.9127841 275.375048
##
## Weights W:
##
##             infl.l5          m.l5          y.l5        cpr.l5        tbr.l5
## infl.d -0.076905806 -4.476970e-02 -0.0503732918  0.0451856048 -0.0520655925
## m.d    -0.000249533  1.600878e-04 -0.0004854944 -0.0003452946  0.0001517958
## y.d    -0.001449370  7.724998e-05 -0.0001018686  0.0004575570  0.0001025061
## cpr.d   0.064149061  9.989139e-03 -0.0289892535  0.0623279416  0.0026641115
## tbr.d   0.047738044 -1.682065e-04 -0.0294019158  0.0532235550  0.0139059927
##             constant
## infl.d -6.471404e-14
## m.d    -3.077914e-16
## y.d    -6.298405e-16
## cpr.d   1.378946e-14
## tbr.d   1.232139e-15``````
``````eigen.6 = ca.jo(df[, -1], type="eigen", ecdet="const", K=6)
summary(eigen.6)``````
``````##
## ######################
## # Johansen-Procedure #
## ######################
##
## Test type: maximal eigenvalue statistic (lambda max) , without linear trend and constant in cointegration
##
## Eigenvalues (lambda):
## [1]  2.690240e-01  1.971095e-01  1.299891e-01  7.253771e-02  1.732417e-02
## [6] -1.882436e-16
##
## Values of teststatistic and critical values of test:
##
##           test 10pct  5pct  1pct
## r <= 4 |  2.76  7.52  9.24 12.97
## r <= 3 | 11.90 13.75 15.67 20.20
## r <= 2 | 22.00 19.77 22.00 26.81
## r <= 1 | 34.69 25.56 28.14 33.24
## r = 0  | 49.51 31.66 34.40 39.79
##
## Eigenvectors, normalised to first column:
## (These are the cointegration relations)
##
##              infl.l6       m.l6        y.l6     cpr.l6      tbr.l6   constant
## infl.l6     1.000000    1.00000    1.000000  1.0000000   1.0000000    1.00000
## m.l6       36.334894  204.19217   57.751754  1.6133149 -10.1762449 -200.70476
## y.l6      -15.962519  -74.54249  -31.016102 -2.8609857   7.2899859  -27.84829
## cpr.l6     -4.676546   98.22571   -3.901578 -0.1247101   0.7361456   28.87986
## tbr.l6      5.764312  -94.35876    6.197234 -0.6761898  -1.3263551  -25.04501
## constant -115.861539 -832.43682 -134.719135 13.3510670   5.0054743 1448.32325
##
## Weights W:
##
##              infl.l6          m.l6          y.l6        cpr.l6        tbr.l6
## infl.d -9.120064e-02  8.038836e-03 -1.090757e-01  0.0438439893 -4.825389e-02
## m.d    -9.171581e-05 -9.180989e-05 -2.395308e-04 -0.0004508571  1.371533e-04
## y.d    -1.475957e-03 -5.898253e-05  4.127615e-05  0.0006668840 -1.867595e-05
## cpr.d   8.931169e-02 -3.201404e-03 -1.888907e-02  0.0863241017 -1.684758e-03
## tbr.d   4.960367e-02 -1.101318e-03 -2.911223e-02  0.0784889361  8.438562e-03
##             constant
## infl.d -1.763205e-14
## m.d    -2.650060e-16
## y.d    -2.364325e-16
## cpr.d  -5.776105e-15
## tbr.d  -8.371206e-15``````

## 9.15 Table 9.15

ML estimates of cointegrating vectors

``````md = data.frame(df\$m, df\$infl, df\$y, df\$tbr)
md.6 = ca.jo(md, type="eigen", ecdet="const", K=6)
summary(md.6)``````
``````##
## ######################
## # Johansen-Procedure #
## ######################
##
## Test type: maximal eigenvalue statistic (lambda max) , without linear trend and constant in cointegration
##
## Eigenvalues (lambda):
## [1]  2.430975e-01  1.230206e-01  6.779006e-02  1.956202e-02 -2.710379e-16
##
## Values of teststatistic and critical values of test:
##
##           test 10pct  5pct  1pct
## r <= 3 |  3.12  7.52  9.24 12.97
## r <= 2 | 11.09 13.75 15.67 20.20
## r <= 1 | 20.74 19.77 22.00 26.81
## r = 0  | 44.01 25.56 28.14 33.24
##
## Eigenvectors, normalised to first column:
## (These are the cointegration relations)
##
##                df.m.l6  df.infl.l6    df.y.l6   df.tbr.l6     constant
## df.m.l6     1.00000000  1.00000000  1.0000000  1.00000000   1.00000000
## df.infl.l6  0.02522691  0.01302547  0.5800574 -0.06852558  -0.01314323
## df.y.l6    -0.43486245 -0.51786656 -1.1256148 -0.42825578   0.73439460
## df.tbr.l6   0.02697521  0.03907833 -0.4986329  0.02561792  -0.05203717
## constant   -3.29379438 -2.51378290  3.3856274 -2.80155676 -11.86397447
##
## Weights W:
##
##               df.m.l6    df.infl.l6       df.y.l6     df.tbr.l6      constant
## df.m.d    -0.02556870 -0.0222033813 -0.0007883538 -0.0032729768 -1.266765e-14
## df.infl.d -2.30607010 -3.8089602070  0.0646000111  0.9813842141 -1.296247e-12
## df.y.d    -0.06005143 -0.0007372116  0.0013358677 -0.0007555107 -1.755969e-14
## df.tbr.d   1.78182874 -2.2913872495  0.1266841367 -0.1123889704 -1.300095e-14``````
``````rp = data.frame(df\$cpr, df\$infl, df\$y, df\$tbr)
rp.6 = ca.jo(rp, type="eigen", ecdet="const", K=6)
summary(rp.6)``````
``````##
## ######################
## # Johansen-Procedure #
## ######################
##
## Test type: maximal eigenvalue statistic (lambda max) , without linear trend and constant in cointegration
##
## Eigenvalues (lambda):
## [1] 2.033097e-01 1.152047e-01 4.507482e-02 2.911010e-02 3.207203e-16
##
## Values of teststatistic and critical values of test:
##
##           test 10pct  5pct  1pct
## r <= 3 |  4.67  7.52  9.24 12.97
## r <= 2 |  7.29 13.75 15.67 20.20
## r <= 1 | 19.34 19.77 22.00 26.81
## r = 0  | 35.91 25.56 28.14 33.24
##
## Eigenvectors, normalised to first column:
## (These are the cointegration relations)
##
##             df.cpr.l6  df.infl.l6     df.y.l6  df.tbr.l6      constant
## df.cpr.l6   1.0000000  1.00000000   1.0000000  1.0000000   1.000000000
## df.infl.l6 -0.1372333 -0.01129626   0.5335812 -1.0340607   0.005299823
## df.y.l6    -0.3586022  0.16036590   3.5488249  1.2646617  11.287621216
## df.tbr.l6  -0.9315895 -1.01073363  -2.3294569 -0.7822223  -1.424690005
## constant    3.1739647 -2.21538165 -22.7777993 -7.3701421 -87.989126221
##
## Weights W:
##
##              df.cpr.l6   df.infl.l6      df.y.l6     df.tbr.l6      constant
## df.cpr.d  -0.500577200 -0.356905834 0.0375056148 -0.0043169541  1.049438e-15
## df.infl.d -0.067177872  0.587825534 0.0586485985  0.1239229209 -1.159858e-14
## df.y.d     0.002984518 -0.005698168 0.0005505938  0.0000244601  3.412406e-17
## df.tbr.d  -0.360211378 -0.075795367 0.0443907971 -0.0165170383 -1.323401e-15``````

## 9.16 Table 9.16

``````df\$ecm1 = as.matrix(md)%*%md.6@V[1:ncol(md), 1]
df\$ecm2 = as.matrix(rp)%*%rp.6@V[1:ncol(rp), 1]
df <- df%>%
mutate(dm = m - lag(m, 1),
dinfl = infl - lag(infl, 1),
dcpr = cpr - lag(cpr, 1),
dy = y - lag(y, 1),
dtbr = tbr - lag(tbr, 1),
ecm1t = lag(ecm1, 1),
ecm2t = lag(ecm2, 1)
)
summary(lm(ecm1t ~ dm + dinfl + dcpr + dy + dtbr, data = df))``````
``````##
## Call:
## lm(formula = ecm1t ~ dm + dinfl + dcpr + dy + dtbr, data = df)
##
## Residuals:
##       Min        1Q    Median        3Q       Max
## -0.141479 -0.033344 -0.000882  0.036622  0.136619
##
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)
## (Intercept)  3.1973739  0.0056192 569.007  < 2e-16 ***
## dm          -3.6105953  0.4079460  -8.851 1.73e-15 ***
## dinfl       -0.0142605  0.0025745  -5.539 1.25e-07 ***
## dcpr         0.0003991  0.0133508   0.030  0.97619
## dy          -1.7000807  0.5343018  -3.182  0.00176 **
## dtbr         0.0089148  0.0154692   0.576  0.56524
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.05464 on 157 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  0.4698, Adjusted R-squared:  0.453
## F-statistic: 27.83 on 5 and 157 DF,  p-value: < 2.2e-16``````