Direction

Obtain monthly data for federal funds rate and for Moody’s AAA rated corporate bonds. Monetary transmission mechanism assumes that changes in FED’s interest rate lead to changes in the interest rate lead to changes in the interest rates at which the firms can borrow, which implies that these two times series should be cointegrated

a) Plot the two time series in the same graph. Test both series and their first difference to verify that they are I(1)

First we need to load the data that we are going to use to solve this problem

fundr<-Quandl("FRED/FEDFUNDS", type="ts")
dfundr<-diff(fundr)
bonds<-Quandl("FED/RIMLPAAAR_N_M", type="ts")
dbonds<-diff(bonds)
y <- cbind(fundr,bonds)
ts.plot(fundr, bonds, gpars = list(col = c("black", "red")))

From the plot we see that both time series showing a similar movement, now we test with the unit root test, differentiate both data and test the unit root again to proof that they are integrated in order 1, in the levels:

summary( ur.df(fundr, lags=12, selectlags="AIC", type="trend") )

############################################### 
# Augmented Dickey-Fuller Test Unit Root Test # 
############################################### 

Test regression trend 


Call:
lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)

Residuals:
    Min      1Q  Median      3Q     Max 
-6.0929 -0.1209 -0.0101  0.1200  2.9561 

Coefficients:
               Estimate Std. Error t value Pr(>|t|)    
(Intercept)   1.058e-01  4.790e-02   2.208 0.027561 *  
z.lag.1      -1.210e-02  5.040e-03  -2.400 0.016642 *  
tt           -1.226e-04  8.268e-05  -1.483 0.138392    
z.diff.lag1   4.304e-01  3.705e-02  11.617  < 2e-16 ***
z.diff.lag2  -1.062e-01  4.033e-02  -2.633 0.008655 ** 
z.diff.lag3   7.420e-03  4.031e-02   0.184 0.854019    
z.diff.lag4  -8.758e-02  3.999e-02  -2.190 0.028841 *  
z.diff.lag5   2.385e-02  3.963e-02   0.602 0.547442    
z.diff.lag6   1.763e-02  3.964e-02   0.445 0.656525    
z.diff.lag7  -1.569e-01  3.964e-02  -3.959 8.28e-05 ***
z.diff.lag8   1.469e-01  3.988e-02   3.683 0.000247 ***
z.diff.lag9   1.228e-01  4.026e-02   3.049 0.002377 ** 
z.diff.lag10 -4.297e-02  4.028e-02  -1.067 0.286407    
z.diff.lag11 -1.022e-01  3.714e-02  -2.753 0.006049 ** 
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 0.452 on 715 degrees of freedom
Multiple R-squared:  0.2446,    Adjusted R-squared:  0.2309 
F-statistic: 17.81 on 13 and 715 DF,  p-value: < 2.2e-16


Value of test-statistic is: -2.4002 2.2006 3.2968 

Critical values for test statistics: 
      1pct  5pct 10pct
tau3 -3.96 -3.41 -3.12
phi2  6.09  4.68  4.03
phi3  8.27  6.25  5.34
summary( ur.ers(fundr, type="P-test", lag.max=8, model="trend") )

############################################### 
# Elliot, Rothenberg and Stock Unit Root Test # 
############################################### 

Test of type P-test 
detrending of series with intercept and trend 

Value of test-statistic is: 11.765 

Critical values of P-test are:
                1pct 5pct 10pct
critical values 3.96 5.62  6.89
summary( ur.za(fundr, model="trend") )

################################ 
# Zivot-Andrews Unit Root Test # 
################################ 


Call:
lm(formula = testmat)

Residuals:
    Min      1Q  Median      3Q     Max 
-6.3697 -0.1184  0.0107  0.1399  3.2566 

Coefficients:
              Estimate Std. Error t value Pr(>|t|)    
(Intercept)  0.0535559  0.0543708   0.985  0.32494    
y.l1         0.9658419  0.0092105 104.863  < 2e-16 ***
trend        0.0009674  0.0003847   2.515  0.01213 *  
dt          -0.0018805  0.0006340  -2.966  0.00311 ** 
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 0.5078 on 737 degrees of freedom
  (1 observation deleted due to missingness)
Multiple R-squared:  0.9802,    Adjusted R-squared:  0.9801 
F-statistic: 1.214e+04 on 3 and 737 DF,  p-value: < 2.2e-16


Teststatistic: -3.7086 
Critical values: 0.01= -4.93 0.05= -4.42 0.1= -4.11 

Potential break point at position: 304 
summary( ur.kpss(fundr, lags="short", type="tau") )

####################### 
# KPSS Unit Root Test # 
####################### 

Test is of type: tau with 6 lags. 

Value of test-statistic is: 1.7917 

Critical value for a significance level of: 
                10pct  5pct 2.5pct  1pct
critical values 0.119 0.146  0.176 0.216

We see that all the test mostly shows that on the level, Fundr is not stationary, now lets test for bonds data, the test also showing the same result

summary( ur.df(bonds, lags=12, selectlags="AIC", type="trend") )

############################################### 
# Augmented Dickey-Fuller Test Unit Root Test # 
############################################### 

Test regression trend 


Call:
lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.92010 -0.05281 -0.00391  0.05231  1.13014 

Coefficients:
               Estimate Std. Error t value Pr(>|t|)    
(Intercept)   1.393e-02  1.214e-02   1.148  0.25129    
z.lag.1      -3.335e-03  2.006e-03  -1.663  0.09666 .  
tt            7.817e-06  1.615e-05   0.484  0.62854    
z.diff.lag1   4.033e-01  2.959e-02  13.630  < 2e-16 ***
z.diff.lag2  -2.172e-01  3.192e-02  -6.804 1.64e-11 ***
z.diff.lag3   2.737e-02  3.256e-02   0.841  0.40068    
z.diff.lag4  -9.178e-04  3.252e-02  -0.028  0.97749    
z.diff.lag5   9.410e-02  3.251e-02   2.895  0.00387 ** 
z.diff.lag6  -4.004e-02  3.260e-02  -1.228  0.21962    
z.diff.lag7  -4.757e-02  3.250e-02  -1.464  0.14360    
z.diff.lag8   8.603e-02  3.253e-02   2.644  0.00829 ** 
z.diff.lag9   4.144e-02  3.275e-02   1.265  0.20599    
z.diff.lag10  2.364e-02  3.212e-02   0.736  0.46190    
z.diff.lag11  4.617e-02  2.981e-02   1.549  0.12174    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 0.1617 on 1138 degrees of freedom
Multiple R-squared:  0.1773,    Adjusted R-squared:  0.1679 
F-statistic: 18.87 on 13 and 1138 DF,  p-value: < 2.2e-16


Value of test-statistic is: -1.6626 0.9663 1.432 

Critical values for test statistics: 
      1pct  5pct 10pct
tau3 -3.96 -3.41 -3.12
phi2  6.09  4.68  4.03
phi3  8.27  6.25  5.34
summary( ur.ers(bonds, type="P-test", lag.max=8, model="trend") )

############################################### 
# Elliot, Rothenberg and Stock Unit Root Test # 
############################################### 

Test of type P-test 
detrending of series with intercept and trend 

Value of test-statistic is: 27.783 

Critical values of P-test are:
                1pct 5pct 10pct
critical values 3.96 5.62  6.89
summary( ur.za(bonds, model="trend") )

################################ 
# Zivot-Andrews Unit Root Test # 
################################ 


Call:
lm(formula = testmat)

Residuals:
     Min       1Q   Median       3Q      Max 
-1.15118 -0.05421 -0.01109  0.05358  1.29034 

Coefficients:
              Estimate Std. Error t value Pr(>|t|)    
(Intercept)  2.292e-03  1.336e-02   0.172  0.86378    
y.l1         9.936e-01  2.569e-03 386.791  < 2e-16 ***
trend        9.270e-05  3.439e-05   2.696  0.00712 ** 
dt          -2.688e-04  8.306e-05  -3.236  0.00125 ** 
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 0.1758 on 1160 degrees of freedom
  (1 observation deleted due to missingness)
Multiple R-squared:  0.9957,    Adjusted R-squared:  0.9957 
F-statistic: 9.041e+04 on 3 and 1160 DF,  p-value: < 2.2e-16


Teststatistic: -2.481 
Critical values: 0.01= -4.93 0.05= -4.42 0.1= -4.11 

Potential break point at position: 744 
summary( ur.kpss(bonds, lags="short", type="tau") )

####################### 
# KPSS Unit Root Test # 
####################### 

Test is of type: tau with 7 lags. 

Value of test-statistic is: 1.6812 

Critical value for a significance level of: 
                10pct  5pct 2.5pct  1pct
critical values 0.119 0.146  0.176 0.216

Testing for the first different data:

summary( ur.df(dfundr, lags=12, selectlags="AIC", type="trend") )

############################################### 
# Augmented Dickey-Fuller Test Unit Root Test # 
############################################### 

Test regression trend 


Call:
lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)

Residuals:
    Min      1Q  Median      3Q     Max 
-6.1868 -0.1153  0.0138  0.1214  2.9086 

Coefficients:
               Estimate Std. Error t value Pr(>|t|)    
(Intercept)   2.023e-02  3.430e-02   0.590  0.55548    
z.lag.1      -6.926e-01  1.012e-01  -6.841 1.70e-11 ***
tt           -5.842e-05  7.973e-05  -0.733  0.46392    
z.diff.lag1   1.203e-01  9.679e-02   1.243  0.21425    
z.diff.lag2   2.310e-02  9.255e-02   0.250  0.80297    
z.diff.lag3   3.418e-02  8.897e-02   0.384  0.70095    
z.diff.lag4  -7.702e-02  8.577e-02  -0.898  0.36952    
z.diff.lag5  -8.383e-02  8.091e-02  -1.036  0.30051    
z.diff.lag6  -4.572e-02  7.358e-02  -0.621  0.53453    
z.diff.lag7  -2.101e-01  6.821e-02  -3.081  0.00214 ** 
z.diff.lag8  -7.162e-02  6.220e-02  -1.151  0.24994    
z.diff.lag9   6.077e-02  5.520e-02   1.101  0.27137    
z.diff.lag10  1.042e-02  4.944e-02   0.211  0.83313    
z.diff.lag11 -7.435e-02  4.260e-02  -1.745  0.08136 .  
z.diff.lag12 -1.583e-01  3.691e-02  -4.289 2.04e-05 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 0.4485 on 713 degrees of freedom
Multiple R-squared:  0.3992,    Adjusted R-squared:  0.3874 
F-statistic: 33.84 on 14 and 713 DF,  p-value: < 2.2e-16


Value of test-statistic is: -6.8406 15.6037 23.4045 

Critical values for test statistics: 
      1pct  5pct 10pct
tau3 -3.96 -3.41 -3.12
phi2  6.09  4.68  4.03
phi3  8.27  6.25  5.34
summary( ur.ers(dfundr, type="P-test", lag.max=8, model="trend") )

############################################### 
# Elliot, Rothenberg and Stock Unit Root Test # 
############################################### 

Test of type P-test 
detrending of series with intercept and trend 

Value of test-statistic is: 0.4538 

Critical values of P-test are:
                1pct 5pct 10pct
critical values 3.96 5.62  6.89
summary( ur.za(dfundr, model="trend") )

################################ 
# Zivot-Andrews Unit Root Test # 
################################ 


Call:
lm(formula = testmat)

Residuals:
    Min      1Q  Median      3Q     Max 
-6.7923 -0.1021  0.0147  0.1071  2.9395 

Coefficients: (1 not defined because of singularities)
              Estimate Std. Error t value Pr(>|t|)    
(Intercept)  1.953e-02  3.496e-02   0.559    0.577    
y.l1         3.805e-01  3.405e-02  11.176   <2e-16 ***
trend       -5.504e-05  8.159e-05  -0.675    0.500    
dt                  NA         NA      NA       NA    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 0.4737 on 737 degrees of freedom
  (1 observation deleted due to missingness)
Multiple R-squared:  0.1462,    Adjusted R-squared:  0.1438 
F-statistic: 63.08 on 2 and 737 DF,  p-value: < 2.2e-16


Teststatistic: -18.1935 
Critical values: 0.01= -4.93 0.05= -4.42 0.1= -4.11 

Potential break point at position: 1 
summary( ur.kpss(dfundr, lags="short", type="tau") )

####################### 
# KPSS Unit Root Test # 
####################### 

Test is of type: tau with 6 lags. 

Value of test-statistic is: 0.0229 

Critical value for a significance level of: 
                10pct  5pct 2.5pct  1pct
critical values 0.119 0.146  0.176 0.216

For Fundr, after differentiated, most of the test conclude that the data is now stationary, means that Fundr is I(1), the same thing also shown by bonds data after differentiated

summary( ur.df(dbonds, lags=12, selectlags="AIC", type="trend") )

############################################### 
# Augmented Dickey-Fuller Test Unit Root Test # 
############################################### 

Test regression trend 


Call:
lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.92586 -0.05144 -0.00105  0.05372  1.11744 

Coefficients:
               Estimate Std. Error t value Pr(>|t|)    
(Intercept)   1.694e-03  9.694e-03   0.175   0.8613    
z.lag.1      -6.617e-01  7.698e-02  -8.596   <2e-16 ***
tt           -4.706e-06  1.437e-05  -0.328   0.7433    
z.diff.lag1   6.378e-02  7.546e-02   0.845   0.3982    
z.diff.lag2  -1.519e-01  7.341e-02  -2.069   0.0388 *  
z.diff.lag3  -1.245e-01  7.106e-02  -1.752   0.0800 .  
z.diff.lag4  -1.219e-01  6.845e-02  -1.781   0.0752 .  
z.diff.lag5  -2.790e-02  6.539e-02  -0.427   0.6697    
z.diff.lag6  -7.418e-02  6.116e-02  -1.213   0.2254    
z.diff.lag7  -1.220e-01  5.717e-02  -2.135   0.0330 *  
z.diff.lag8  -3.407e-02  5.357e-02  -0.636   0.5249    
z.diff.lag9   6.431e-03  4.831e-02   0.133   0.8941    
z.diff.lag10  1.981e-02  4.223e-02   0.469   0.6391    
z.diff.lag11  6.969e-02  3.462e-02   2.013   0.0444 *  
z.diff.lag12  4.658e-02  2.989e-02   1.558   0.1194    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 0.1617 on 1136 degrees of freedom
Multiple R-squared:  0.3881,    Adjusted R-squared:  0.3806 
F-statistic: 51.46 on 14 and 1136 DF,  p-value: < 2.2e-16


Value of test-statistic is: -8.5956 24.6353 36.9524 

Critical values for test statistics: 
      1pct  5pct 10pct
tau3 -3.96 -3.41 -3.12
phi2  6.09  4.68  4.03
phi3  8.27  6.25  5.34
summary( ur.ers(dbonds, type="P-test", lag.max=8, model="trend") )

############################################### 
# Elliot, Rothenberg and Stock Unit Root Test # 
############################################### 

Test of type P-test 
detrending of series with intercept and trend 

Value of test-statistic is: 0.1118 

Critical values of P-test are:
                1pct 5pct 10pct
critical values 3.96 5.62  6.89
summary( ur.za(dbonds, model="trend") )

################################ 
# Zivot-Andrews Unit Root Test # 
################################ 


Call:
lm(formula = testmat)

Residuals:
     Min       1Q   Median       3Q      Max 
-1.15582 -0.05267 -0.00395  0.04967  1.17003 

Coefficients:
              Estimate Std. Error t value Pr(>|t|)    
(Intercept) -1.218e-02  1.283e-02  -0.949   0.3427    
y.l1         3.246e-01  2.778e-02  11.683   <2e-16 ***
trend        4.505e-05  3.157e-05   1.427   0.1538    
dt          -1.081e-04  5.847e-05  -1.848   0.0648 .  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 0.1667 on 1159 degrees of freedom
  (1 observation deleted due to missingness)
Multiple R-squared:  0.1109,    Adjusted R-squared:  0.1086 
F-statistic: 48.18 on 3 and 1159 DF,  p-value: < 2.2e-16


Teststatistic: -24.308 
Critical values: 0.01= -4.93 0.05= -4.42 0.1= -4.11 

Potential break point at position: 599 
summary( ur.kpss(dbonds, lags="short", type="tau") )

####################### 
# KPSS Unit Root Test # 
####################### 

Test is of type: tau with 7 lags. 

Value of test-statistic is: 0.1527 

Critical value for a significance level of: 
                10pct  5pct 2.5pct  1pct
critical values 0.119 0.146  0.176 0.216

b) Trace and Max Eigenvalue Test to determine whether two series are cointegrated

y.CA <- ca.jo(y, ecdet="const", type="trace", K=2, spec="transitory", season=4)
summary(y.CA)

###################### 
# Johansen-Procedure # 
###################### 

Test type: trace statistic , without linear trend and constant in cointegration 

Eigenvalues (lambda):
[1] 5.656315e-02 6.238040e-03 1.626303e-19

Values of teststatistic and critical values of test:

          test 10pct  5pct  1pct
r <= 1 |  4.61  7.52  9.24 12.97
r = 0  | 47.52 17.85 19.96 24.60

Eigenvectors, normalised to first column:
(These are the cointegration relations)

          fundr.l1   bonds.l1   constant
fundr.l1  1.000000    1.00000   1.000000
bonds.l1 -1.156515   70.76426  -1.399357
constant  3.114892 -500.09370 -55.631528

Weights W:
(This is the loading matrix)

           fundr.l1      bonds.l1      constant
fundr.d -0.03644358 -0.0001496004 -4.276118e-19
bonds.d  0.01592491 -0.0000666063  2.126652e-19
y.CA <- ca.jo(y, ecdet="const", type="eigen", K=2, spec="transitory", season=4)
summary(y.CA)

###################### 
# Johansen-Procedure # 
###################### 

Test type: maximal eigenvalue statistic (lambda max) , without linear trend and constant in cointegration 

Eigenvalues (lambda):
[1] 5.656315e-02 6.238040e-03 1.626303e-19

Values of teststatistic and critical values of test:

          test 10pct  5pct  1pct
r <= 1 |  4.61  7.52  9.24 12.97
r = 0  | 42.91 13.75 15.67 20.20

Eigenvectors, normalised to first column:
(These are the cointegration relations)

          fundr.l1   bonds.l1   constant
fundr.l1  1.000000    1.00000   1.000000
bonds.l1 -1.156515   70.76426  -1.399357
constant  3.114892 -500.09370 -55.631528

Weights W:
(This is the loading matrix)

           fundr.l1      bonds.l1      constant
fundr.d -0.03644358 -0.0001496004 -4.276118e-19
bonds.d  0.01592491 -0.0000666063  2.126652e-19

Both of the trace statistics and eigenvalue proving that we cannot reject Hypothesis null of unit roots in residuals means that fundr and bonds data are cointegrated

c) Testing for presence of restricted constant

lttest(y.CA, r=1)
LR-test for no linear trend

H0: H*2(r<=1)
H1: H2(r<=1)

Test statistic is distributed as chi-square
with 1 degress of freedom
        test statistic p-value
LR test              0    0.98

From the test result, the ecdet="const" is appropriate.

d) Test the restriction \(\beta{2}=-1\)

rest.b1 <- matrix(c(0,-1,0,   0,0,1), c(3,2))
A.rb1 <- blrtest(y.CA, H=rest.b1, r=1)
summary(A.rb1)

###################### 
# Johansen-Procedure # 
###################### 

Estimation and testing under linear restrictions on beta 

The VECM has been estimated subject to: 
beta=H*phi and/or alpha=A*psi

     [,1] [,2]
[1,]    0    0
[2,]   -1    0
[3,]    0    1

Eigenvalues of restricted VAR (lambda):
[1] 0.0062 0.0001

The value of the likelihood ratio test statistic:
38.3 distributed as chi square with 1 df.
The p-value of the test statistic is: 0 

Eigenvectors, normalised to first column
of the restricted VAR:

     [,1] [,2]
[1,]  NaN  NaN
[2,] -Inf  Inf
[3,]  Inf  Inf

Weights W of the restricted VAR:

        [,1] [,2]
fundr.d  NaN  NaN
bonds.d  NaN  NaN

From the test result, we cannot reject \(\beta{2}=-1\).

e) Plot of the Error Term

plotres(y.CA)