The first step is to obtain monthly time series for federal funds rate, FRED/FEDFUNDS and for Moody’s AAA rated corporate bonds, FED/RIMLPAAAR_N_M.
FUNDS <- Quandl("FRED/FEDFUNDS", type="ts")
AAA <- Quandl("FED/RIMLPAAAR_N_M", type="ts")
The following figures shows the series.
FUNDS <- window(FUNDS,start=c(1954,7), end =c(2016,1))
AAA <- window(AAA,start=c(1954,7), end =c(2016,1))
ts.plot(FUNDS, AAA, gpars = list(col = c("black", "red")))
The next step is to test for the stationary for both FRED/FEDFUNDS and FED/RIMLPAAAR_N_M.
y1t.adf <- adf.test(FUNDS)
y1t.adf
Augmented Dickey-Fuller Test
data: FUNDS
Dickey-Fuller = -2.887, Lag order = 9, p-value = 0.2028
alternative hypothesis: stationary
y2t.adf <- adf.test(AAA)
y2t.adf
Augmented Dickey-Fuller Test
data: AAA
Dickey-Fuller = -1.5624, Lag order = 10, p-value = 0.7636
alternative hypothesis: stationary
From the ADF test we can conclude that both FRED/FEDFUNDS and FED/RIMLPAAAR_N_M are non-stationary (has an unit-root).
The next step that we have to take is to take first difference of the series and retest the series for non-stationarity. We construct new series \(\Delta y_{1,t} = \Delta FUNDS\) and \(\Delta y_{1,t} =\Delta AAA\) using the following code
dy1t <- diff(FUNDS)
dy2t <- diff(AAA)
Next, we redo the ADF test for both \(\Delta y_{1,t}\) and \(\Delta y_{2,t}\):
dy1t.adf <- adf.test(dy1t)
dy1t.adf
Augmented Dickey-Fuller Test
data: dy1t
Dickey-Fuller = -8.1704, Lag order = 9, p-value = 0.01
alternative hypothesis: stationary
dy2t.adf <- adf.test(dy2t)
dy2t.adf
Augmented Dickey-Fuller Test
data: dy2t
Dickey-Fuller = -8.3648, Lag order = 10, p-value = 0.01
alternative hypothesis: stationary
From the ADF test above for \(\Delta y_{1,t}\) and \(\Delta y_{2,t}\), we can see that both of the series were stationary. Hence, we can verify that FRED/FEDFUNDS and FED/RIMLPAAAR_N_M are \(I(1)\).
Before conducting trace and max eigenvalue test, we need to bind \(y_{1,t}\) and \(y_{2,t}\) into one data frame \(y_{t}\), where \(y_{t} = (y_{1,t},y_{2,t})\)
y <- cbind(dy1t,dy2t)
Trace test:
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] 3.703446e-01 2.936162e-01 5.551115e-17
Values of teststatistic and critical values of test:
test 10pct 5pct 1pct
r <= 1 | 255.83 7.52 9.24 12.97
r = 0 | 596.29 17.85 19.96 24.60
Eigenvectors, normalised to first column:
(These are the cointegration relations)
dy1t.l1 dy2t.l1 constant
dy1t.l1 1.000000000 1.0000000000 1.0000000
dy2t.l1 -4.555133313 0.3952395593 -0.9640797
constant 0.007826888 0.0001116057 362.8936736
Weights W:
(This is the loading matrix)
dy1t.l1 dy2t.l1 constant
dy1t.d -0.1389651 -0.6110348 2.222487e-22
dy2t.d 0.1772977 -0.1416213 6.661878e-22
Trace test suggests that \(y_t\) are cointegrated, we can reject \(H_0: rank(\Pi) = 0\) and afterward also reject \(H_0: rank(\Pi) = 1\).
Max Eigenvalue test:
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] 3.703446e-01 2.936162e-01 5.551115e-17
Values of teststatistic and critical values of test:
test 10pct 5pct 1pct
r <= 1 | 255.83 7.52 9.24 12.97
r = 0 | 340.46 13.75 15.67 20.20
Eigenvectors, normalised to first column:
(These are the cointegration relations)
dy1t.l1 dy2t.l1 constant
dy1t.l1 1.000000000 1.0000000000 1.0000000
dy2t.l1 -4.555133313 0.3952395593 -0.9640797
constant 0.007826888 0.0001116057 362.8936736
Weights W:
(This is the loading matrix)
dy1t.l1 dy2t.l1 constant
dy1t.d -0.1389651 -0.6110348 2.222487e-22
dy2t.d 0.1772977 -0.1416213 6.661878e-22
Max eigenvalue test also suggests that \(y_t\) are cointegrated, we can first reject \(H_0: rank(\Pi) = 0\) and afterward also reject \(H_0: rank(\Pi) = 1\).
Hypothesis testing with \(H_0\): restricted constant (case 2) against \(H_A:\) drift (case 3) is implemented using lttest:
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.99
From the test result above, we can see that we cannot reject the restriced constant (\(H_0\)), hence the ecdet="const" is appropriate.
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.349 0.000
The value of the likelihood ratio test statistic:
24.56 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]
dy1t.d NaN NaN
dy2t.d NaN NaN
From the \(p-value = 0.000\), we cannot reject \(\beta{2}=-1\).
plotres(y.CA)