I first obtain monthly for federal funds rate FRED/FEDFUNDS and for Moody’s AAA rated corporate bonds FED/RIMLPAAAR_N_M. These two time series should be co-integrated.
First we load the “Quandl” packages and etc.
library("Quandl")
library("vars")
library("gdata")
library("stargazer")
We plot both series in the same plot, and also plot their first differences.
ff<-Quandl("FRED/FEDFUNDS", type="zoo")
mood<-Quandl("FED/RIMLPAAAR_N_M", type="zoo")
ff<-window(ff,start="Jan 1960", end="Jan 2016")
mood<-window(mood,start="Jan 1960", end="Jan 2016")
ffd<-diff(ff,1)
moodd<-diff(mood,1)
par(mfrow=c(1,2))
plot(ff,xlab="Year", ylab="Interest Rate", col="red", main="Fed Funds and AAA Bonds")
lines(mood, col="blue")
legend("topleft", c("Fed Funds","AAA Bonds"),lty=c(1,1), col=c("red", "blue"))
par(mfrow=c(1,2))
plot(ffd,xlab="Year", ylab="Interest Rate", col="red", main="First Diff Fed Funds")
plot(moodd,xlab="Year", ylab="Interest Rate", col="blue", main="First Diff AAA Bonds")
Now we conduct an Elliot Rothenberg and Stock (ERS) unit root test on all four of our variables. The null hypothesis is: \[H_o=Stationary\]
summary( ur.ers(ff, type="P-test",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: 9.0253
##
## Critical values of P-test are:
## 1pct 5pct 10pct
## critical values 3.96 5.62 6.89
summary( ur.ers(mood, type="P-test",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: 44.5105
##
## Critical values of P-test are:
## 1pct 5pct 10pct
## critical values 3.96 5.62 6.89
summary( ur.ers(ffd, type="P-test",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.2257
##
## Critical values of P-test are:
## 1pct 5pct 10pct
## critical values 3.96 5.62 6.89
summary( ur.ers(moodd, type="P-test",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.19
##
## Critical values of P-test are:
## 1pct 5pct 10pct
## critical values 3.96 5.62 6.89
From the summary statistics, we can see that the Federal Funds rate and AAA ratings are not stationary and have a unit root. The first differences of both do not reject the null hypothesis, so the first differences are consistent with being stationary.
I conduct the Johansen’s methodology to perform the trace test and the max eigenvalue test.
two<-cbind(ff,mood)
trace.two<- ca.jo(two, ecdet="const", type="trace", K=2, spec="longrun")
summary(trace.two)
##
## ######################
## # Johansen-Procedure #
## ######################
##
## Test type: trace statistic , without linear trend and constant in cointegration
##
## Eigenvalues (lambda):
## [1] 5.918327e-02 5.939614e-03 9.557320e-19
##
## Values of teststatistic and critical values of test:
##
## test 10pct 5pct 1pct
## r <= 1 | 4.00 7.52 9.24 12.97
## r = 0 | 44.93 17.85 19.96 24.60
##
## Eigenvectors, normalised to first column:
## (These are the cointegration relations)
##
## ff.l2 mood.l2 constant
## ff.l2 1.000000 1.00000 1.00000
## mood.l2 -1.208595 -73.82892 3.03463
## constant 3.582429 519.39052 -171.64079
##
## Weights W:
## (This is the loading matrix)
##
## ff.l2 mood.l2 constant
## ff.d -0.03729059 1.570362e-04 -2.502138e-20
## mood.d 0.01701971 6.886164e-05 -5.617668e-20
eigen.two<- ca.jo(two, ecdet="const", type="eigen", K=2, spec="longrun")
summary(eigen.two)
##
## ######################
## # Johansen-Procedure #
## ######################
##
## Test type: maximal eigenvalue statistic (lambda max) , without linear trend and constant in cointegration
##
## Eigenvalues (lambda):
## [1] 5.918327e-02 5.939614e-03 9.557320e-19
##
## Values of teststatistic and critical values of test:
##
## test 10pct 5pct 1pct
## r <= 1 | 4.00 7.52 9.24 12.97
## r = 0 | 40.94 13.75 15.67 20.20
##
## Eigenvectors, normalised to first column:
## (These are the cointegration relations)
##
## ff.l2 mood.l2 constant
## ff.l2 1.000000 1.00000 1.00000
## mood.l2 -1.208595 -73.82892 3.03463
## constant 3.582429 519.39052 -171.64079
##
## Weights W:
## (This is the loading matrix)
##
## ff.l2 mood.l2 constant
## ff.d -0.03729059 1.570362e-04 -2.502138e-20
## mood.d 0.01701971 6.886164e-05 -5.617668e-20
The value of the trace test statistic 44.93 is greater than the critical value for \(H_o: rank(r)=0\) but it does not reject \(H_o:rank(r)=1\). Looking at the eigen test, the test statistic 40.94 is greater than the critical value for \(H_o: rank(r)=0\) but it does not reject \(H_o:rank(r)=1\). According to both tests, they suggest that Federal Funds Rate and AAA Bonds are in fact cointegrated with one relationship.
I perform the lltest on the presence of a restricted constant in the model. After running an unrestricted test
two.VEC <- lttest(eigen.two, 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.02 0.88
two.VEC
## test statistic p-value
## LR test 0.02 0.88
I can see that the constant value is 3.58. From our equation:
\[f(FedFunds)=BondRate\]
Let us assume that the function \(f\) is a linear transformation represented by \(\alpha\) and lets log the equation.
\[log(FedFunds)-log(BondRate)+log(\alpha)\]
I can assign \(B_1,B_2,B_3\) a matrix. I first restrict the constant \(B_3=-B_2\). So the test hypothesis is \(H_o: B_3=-B_2\).
mat<- matrix(c(1,0,0,0,1,-1), c(3,2))
eigen.two.beta <- blrtest(eigen.two, H=mat, r=1)
summary(eigen.two.beta)
##
## ######################
## # 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,] 1 0
## [2,] 0 1
## [3,] 0 -1
##
## Eigenvalues of restricted VAR (lambda):
## [1] 0.0492 0.0011
##
## The value of the likelihood ratio test statistic:
## 7.08 distributed as chi square with 1 df.
## The p-value of the test statistic is: 0.01
##
## Eigenvectors, normalised to first column
## of the restricted VAR:
##
## [,1] [,2]
## [1,] 1.0000 1.0000
## [2,] -0.8774 -8.8074
## [3,] 0.8774 8.8074
##
## Weights W of the restricted VAR:
##
## [,1] [,2]
## ff.d -0.0359 2e-04
## mood.d 0.0114 1e-04
The test statistic is significant, so we reject the restriction of \(B_3=-B_2\).
I conduct the same test as in C) but with a different matrix. The null hypothesis is \(H_o:\beta_2=-1\).
mat2<- matrix(c(1,-1,0,0,0,1), c(3,2))
eigen.two.beta2 <- blrtest(eigen.two, H=mat2, r=1)
summary(eigen.two.beta2)
##
## ######################
## # 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,] 1 0
## [2,] -1 0
## [3,] 0 1
##
## Eigenvalues of restricted VAR (lambda):
## [1] 0.0552 0.0000
##
## The value of the likelihood ratio test statistic:
## 2.81 distributed as chi square with 1 df.
## The p-value of the test statistic is: 0.09
##
## Eigenvectors, normalised to first column
## of the restricted VAR:
##
## [,1] [,2]
## [1,] 1.0000 1.0000
## [2,] -1.0000 -1.0000
## [3,] 2.0669 -117.8762
##
## Weights W of the restricted VAR:
##
## [,1] [,2]
## ff.d -0.0385 0
## mood.d 0.0139 0
The results of the test is that we cannot strongly reject the null hypothesis. So it seems that the restriction of \(\beta_2\) of -1 is consistent with the unrestricted tests, and close to the real value of \(\beta_2\).
Plot the residuals from the two restrictions.
plot(eigen.two)
plotres(eigen.two)
car<-cajorls(eigen.two.beta2)