library("zoo")
library("forecast")
library("tseries")
library("urca")
library ("Quandl")
library("vars")
library("Quandl")
Quandl.api_key("DLk9RQrfTVkD4UTKc7op")
library("VARsignR")
library("stargazer")
library("gdata")
Obtain monthly data for federal funds rate FRED/FEDFUNDS and for Moody’s AAA rated corporate bonds FED/RIMLPAAAR_N_M. Monetary transmission mechanism assumes that changes in Fed’s interest rate lead to changes in the interest rates at which the firms can borrow, which implies that these two time series should be cointegrated.
In this problem, data is analysed about Effective Federal Funds Rate and Moody’s AAA rated corporate bonds from 1955 to 2015. The quaterly data for this problem is collectd from Quandl.
Fedfun_d<-Quandl("FRED/FEDFUNDS", type="zoo")
Fedfun <- window(Fedfun_d[,2], start=1955, end=2015)
str(Fedfun)
## 'zooreg' series from Jan 1955 to Jan 2015
## Data: num [1:721] 1.39 1.29 1.35 1.43 1.43 1.64 1.68 1.96 2.18 2.24 ...
## Index: Class 'yearmon' num [1:721] 1955 1955 1955 1955 1955 ...
## Frequency: 12
head(Fedfun)
## Jan 1955 Feb 1955 Mar 1955 Apr 1955 May 1955 Jun 1955
## 1.39 1.29 1.35 1.43 1.43 1.64
tail(Fedfun)
## Aug 2014 Sep 2014 Oct 2014 Nov 2014 Dec 2014 Jan 2015
## 0.09 0.09 0.09 0.09 0.12 0.11
tsdisplay(Fedfun, lag.max = 100, xlab=" Years 1955-2015", ylab= "Percent Not Seasonally Adjusted, Averages of Daily Figures", main ="Effective Federal Funds Rate from 1947 to 2015,Monthly ")
Maaa_d<-Quandl("FED/RIMLPAAAR_N_M", type="zoo")
Maaa <- window(Maaa_d, start=1955, end=2015)
str(Maaa)
## 'zooreg' series from Jan 1955 to Jan 2015
## Data: num [1:721] 2.93 2.93 3.02 3.01 3.04 3.05 3.06 3.11 3.13 3.1 ...
## Index: Class 'yearmon' num [1:721] 1955 1955 1955 1955 1955 ...
## Frequency: 12
head(Maaa)
## Jan 1955 Feb 1955 Mar 1955 Apr 1955 May 1955 Jun 1955
## 2.93 2.93 3.02 3.01 3.04 3.05
tail(Maaa)
## Aug 2014 Sep 2014 Oct 2014 Nov 2014 Dec 2014 Jan 2015
## 4.08 4.11 3.92 3.92 3.79 3.46
tsdisplay(Maaa, lag.max = 100, xlab=" Years 1955-2015", ylab= "Percent", main ="Moody's AAA rated corporate bonds from 1955 to 2015, Monthly")
The monthly data for Effective Federal Funds Rate from 1955 to 2015 has high volatility. The PACF has some peak, while ACF peaks decays very slowly.
The monthly data for Moody’s AAA rated corporate bonds from 1955 to 2015 has high volatility. The PACF does have some peaks, while ACF peaks decays very slowly.
(a) Plot the two time series, in the same graph. Test both series and their first differences for unit root (e.g. using Elliott, Rothenberg and Stock test, or Zivot and Andrews’ test) to verify that they are I(1).
Fedfun_Maaa<-cbind(Fedfun,Maaa)
Fedfun_Maaa1<-window(Fedfun_Maaa)
plot(Fedfun_Maaa1,xlab="year", main="1955-2015")
D_Fedfun<-diff(Fedfun)
D_Maaa<-diff(Maaa)
Fedfun_Maaa1_D<-cbind(D_Fedfun,D_Maaa)
Fedfun_Maaa1_D1<-cbind(Fedfun_Maaa1_D,start="1955", end = "2015")
## Warning in merge.zoo(..., all = all, fill = fill, suffixes = suffixes,
## retclass = "zoo", : Index vectors are of different classes: yearmon integer
## integer
# unit root tests - levels
summary( ur.ers(Fedfun, type="P-test", lag.max=20, 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: 8.9985
##
## Critical values of P-test are:
## 1pct 5pct 10pct
## critical values 3.96 5.62 6.89
summary( ur.ers(Maaa, type="P-test", lag.max=20, 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: 53.2032
##
## Critical values of P-test are:
## 1pct 5pct 10pct
## critical values 3.96 5.62 6.89
# unit root tests - first differences
summary( ur.ers(D_Fedfun, type="P-test", lag.max=20, 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.7785
##
## Critical values of P-test are:
## 1pct 5pct 10pct
## critical values 3.96 5.62 6.89
summary( ur.ers(D_Maaa, type="P-test", lag.max=20, 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.196
##
## Critical values of P-test are:
## 1pct 5pct 10pct
## critical values 3.96 5.62 6.89
Both series are not stationary in levels. The first difference makes both series are stationary. The Effective Federal Funds Rate and Moody’s AAA rated corporate bonds are I(1).
(b) Perform trace and max eigenvalue tests to determine whether the two series are cointegrated. Interpret the results.
# cointegration test - Johansen's methodology
Fedfun_Maaa1_coin1 <- ca.jo(Fedfun_Maaa1, ecdet="const", type="trace", K=2, spec="transitory")
summary(Fedfun_Maaa1_coin1)
##
## ######################
## # Johansen-Procedure #
## ######################
##
## Test type: trace statistic , without linear trend and constant in cointegration
##
## Eigenvalues (lambda):
## [1] 5.777707e-02 6.094588e-03 1.494388e-18
##
## Values of teststatistic and critical values of test:
##
## test 10pct 5pct 1pct
## r <= 1 | 4.40 7.52 9.24 12.97
## r = 0 | 47.19 17.85 19.96 24.60
##
## Eigenvectors, normalised to first column:
## (These are the cointegration relations)
##
## Fedfun.l1 Maaa.l1 constant
## Fedfun.l1 1.000000 1.00000 1.0000000
## Maaa.l1 -1.138264 -92.42882 -0.4731852
## constant 2.948478 642.59810 -102.1371176
##
## Weights W:
## (This is the loading matrix)
##
## Fedfun.l1 Maaa.l1 constant
## Fedfun.d -0.03728995 0.0001183584 6.454488e-19
## Maaa.d 0.01597459 0.0000528520 -1.661029e-19
Fedfun_Maaa1_coin2 <- ca.jo(Fedfun_Maaa1, ecdet="const", type="eigen", K=2, spec="transitory")
summary(Fedfun_Maaa1_coin2)
##
## ######################
## # Johansen-Procedure #
## ######################
##
## Test type: maximal eigenvalue statistic (lambda max) , without linear trend and constant in cointegration
##
## Eigenvalues (lambda):
## [1] 5.777707e-02 6.094588e-03 1.494388e-18
##
## Values of teststatistic and critical values of test:
##
## test 10pct 5pct 1pct
## r <= 1 | 4.40 7.52 9.24 12.97
## r = 0 | 42.79 13.75 15.67 20.20
##
## Eigenvectors, normalised to first column:
## (These are the cointegration relations)
##
## Fedfun.l1 Maaa.l1 constant
## Fedfun.l1 1.000000 1.00000 1.0000000
## Maaa.l1 -1.138264 -92.42882 -0.4731852
## constant 2.948478 642.59810 -102.1371176
##
## Weights W:
## (This is the loading matrix)
##
## Fedfun.l1 Maaa.l1 constant
## Fedfun.d -0.03728995 0.0001183584 6.454488e-19
## Maaa.d 0.01597459 0.0000528520 -1.661029e-19
(c) Perform the test for the presence of a restricted constant rather than unrestricted constant in the model; based on the result of the test rerun the cointegration tests you performed in (b) if necessary.
# test for the presence of the constant term in the cointegration relationship
lttest(Fedfun_Maaa1_coin2, 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.97
(d) Test the restriction \({\beta_2}=-1\), explain what the results of the test suggest.
# test for restricted cointegrating vector betta
# H0: betta2 = -1
rest.betta1 <- matrix(c(0,-1,0,
0,0,1), c(3,2))
A.rbetta1 <- blrtest(Fedfun_Maaa1_coin2, H=rest.betta1, r=1)
summary(A.rbetta1)
##
## ######################
## # 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.0061 0.0000
##
## The value of the likelihood ratio test statistic:
## 38.39 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]
## Fedfun.d NaN NaN
## Maaa.d NaN NaN
(e) Create a plot comparing the error term \({\beta'}y_t\), showing the deviations from long run equilibrium, in the case where \({\beta}\) is unrestricted and the case with restriction \({\beta_2}=-1\). Also add the mean values E(\({\beta'}y_t\)) into the graph.
plotres(Fedfun_Maaa1_coin2)