Problem 1

Data

Monthly Data for Federal Fund Rates and Moody’s AAA rated corporate bonds from Quandl package. The source of data are respectively; FRED/FEDFUNDS FED/RIMLPAAAR_N_M

  1. To plot time series graphs and testing the original series and first difference series for unit root test using different tests.
  2. Performing trace and max eigen value tests to check the cointegration.
  3. To test the test for presence of restricted constants in the model.
  4. Testing the restriction beta two = -1.
  5. To create a plot comparing the error term showing the deviation from the long run equillibrium in the case where beta two is restricted and unrestricted.

Attaching the probable packages to be needed during the work.

library(tseries)
## Warning: package 'tseries' was built under R version 3.2.5
library(Quandl)
## Warning: package 'Quandl' was built under R version 3.2.5
## Loading required package: xts
## Warning: package 'xts' was built under R version 3.2.4
## Loading required package: zoo
## Warning: package 'zoo' was built under R version 3.2.4
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
library(urca)
## Warning: package 'urca' was built under R version 3.2.5
library(vars)
## Warning: package 'vars' was built under R version 3.2.5
## Loading required package: MASS
## Loading required package: strucchange
## Warning: package 'strucchange' was built under R version 3.2.4
## Loading required package: sandwich
## Warning: package 'sandwich' was built under R version 3.2.4
## Loading required package: lmtest
## Warning: package 'lmtest' was built under R version 3.2.4
library(gdata)
## gdata: Unable to locate valid perl interpreter
## gdata: 
## gdata: read.xls() will be unable to read Excel XLS and XLSX files
## gdata: unless the 'perl=' argument is used to specify the location
## gdata: of a valid perl intrpreter.
## gdata: 
## gdata: (To avoid display of this message in the future, please
## gdata: ensure perl is installed and available on the executable
## gdata: search path.)
## gdata: Unable to load perl libaries needed by read.xls()
## gdata: to support 'XLX' (Excel 97-2004) files.
## 
## gdata: Unable to load perl libaries needed by read.xls()
## gdata: to support 'XLSX' (Excel 2007+) files.
## 
## gdata: Run the function 'installXLSXsupport()'
## gdata: to automatically download and install the perl
## gdata: libaries needed to support Excel XLS and XLSX formats.
## 
## Attaching package: 'gdata'
## The following objects are masked from 'package:xts':
## 
##     first, last
## The following object is masked from 'package:stats':
## 
##     nobs
## The following object is masked from 'package:utils':
## 
##     object.size

Getting the data.

FundRate <- Quandl("FRED/FEDFUNDS",api_key="T8gDpM8iFjXR9pfbXBmx",type = "zoo")
MoodyBond <- Quandl("FED/RIMLPAAAR_N_M",api_key="T8gDpM8iFjXR9pfbXBmx",type = "zoo")
BothSeries <- cbind(FundRate,MoodyBond)
TwoSeries <-window(BothSeries,start="Jan 1970", end = "Jan 2016")
plot(TwoSeries, xlab="Years", ylab="1970-2016")

DFundRate <- diff(FundRate)
DMoodyBond <- diff(MoodyBond)
DBothSeries <- cbind(DFundRate,DMoodyBond)
DTwoSeries <- window(DBothSeries, start="Jan 1970", end= "Jan 2016")
plot(DTwoSeries, xlab="Years", ylab="1970-2016")

za.fundrate <- ur.za(FundRate, model="both", lag=2)
summary(za.fundrate)
## 
## ################################ 
## # Zivot-Andrews Unit Root Test # 
## ################################ 
## 
## 
## Call:
## lm(formula = testmat)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -6.1304 -0.1160 -0.0019  0.1108  3.0755 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  0.0951198  0.0574601   1.655 0.098271 .  
## y.l1         0.9532984  0.0091255 104.465  < 2e-16 ***
## trend        0.0009213  0.0003878   2.376 0.017763 *  
## y.dl1        0.4486215  0.0358771  12.504  < 2e-16 ***
## y.dl2       -0.1219341  0.0365158  -3.339 0.000883 ***
## du           0.1824217  0.0783152   2.329 0.020113 *  
## dt          -0.0022615  0.0005799  -3.900 0.000105 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.461 on 732 degrees of freedom
##   (3 observations deleted due to missingness)
## Multiple R-squared:  0.9837, Adjusted R-squared:  0.9836 
## F-statistic:  7364 on 6 and 732 DF,  p-value: < 2.2e-16
## 
## 
## Teststatistic: -5.1177 
## Critical values: 0.01= -5.57 0.05= -5.08 0.1= -4.82 
## 
## Potential break point at position: 286
za.moodybond <- ur.za(MoodyBond, model="both", lag=2)
summary(za.moodybond)
## 
## ################################ 
## # Zivot-Andrews Unit Root Test # 
## ################################ 
## 
## 
## Call:
## lm(formula = testmat)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.95733 -0.05634 -0.00609  0.04599  1.15625 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  3.161e-02  1.941e-02   1.629  0.10367    
## y.l1         9.905e-01  3.013e-03 328.739  < 2e-16 ***
## trend        1.733e-05  4.115e-05   0.421  0.67371    
## y.dl1        3.978e-01  2.855e-02  13.935  < 2e-16 ***
## y.dl2       -2.204e-01  2.859e-02  -7.709 2.71e-14 ***
## du           8.073e-02  2.834e-02   2.849  0.00446 ** 
## dt          -1.891e-04  5.973e-05  -3.166  0.00158 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.162 on 1155 degrees of freedom
##   (3 observations deleted due to missingness)
## Multiple R-squared:  0.9964, Adjusted R-squared:  0.9964 
## F-statistic: 5.331e+04 on 6 and 1155 DF,  p-value: < 2.2e-16
## 
## 
## Teststatistic: -3.1675 
## Critical values: 0.01= -5.57 0.05= -5.08 0.1= -4.82 
## 
## Potential break point at position: 580
za.dfundrate <- ur.za(DFundRate, model="both", lag=2)
summary(za.dfundrate)
## 
## ################################ 
## # Zivot-Andrews Unit Root Test # 
## ################################ 
## 
## 
## Call:
## lm(formula = testmat)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -6.4532 -0.0957 -0.0020  0.1283  2.8525 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -0.0224859  0.0531310  -0.423  0.67226    
## y.l1         0.2454382  0.0486259   5.047 5.66e-07 ***
## trend        0.0004056  0.0002843   1.427  0.15411    
## y.dl1        0.1831347  0.0418497   4.376 1.38e-05 ***
## y.dl2        0.0364765  0.0368553   0.990  0.32264    
## du          -0.1981334  0.0699115  -2.834  0.00472 ** 
## dt          -0.0001387  0.0003407  -0.407  0.68411    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4667 on 731 degrees of freedom
##   (3 observations deleted due to missingness)
## Multiple R-squared:  0.1776, Adjusted R-squared:  0.1708 
## F-statistic: 26.31 on 6 and 731 DF,  p-value: < 2.2e-16
## 
## 
## Teststatistic: -15.5177 
## Critical values: 0.01= -5.57 0.05= -5.08 0.1= -4.82 
## 
## Potential break point at position: 322
za.dmoodybond <- ur.za(DMoodyBond, model="both", lag=2)
summary(za.dmoodybond)
## 
## ################################ 
## # Zivot-Andrews Unit Root Test # 
## ################################ 
## 
## 
## Call:
## lm(formula = testmat)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.95446 -0.05505 -0.00822  0.04822  1.09481 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -2.636e-02  1.191e-02  -2.213 0.027083 *  
## y.l1         1.566e-01  4.170e-02   3.757 0.000181 ***
## trend        9.964e-05  2.758e-05   3.613 0.000316 ***
## y.dl1        2.293e-01  3.368e-02   6.808 1.58e-11 ***
## y.dl2       -1.362e-02  2.932e-02  -0.465 0.642368    
## du          -1.008e-01  2.023e-02  -4.985 7.13e-07 ***
## dt           4.011e-05  7.207e-05   0.557 0.577965    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.1611 on 1154 degrees of freedom
##   (3 observations deleted due to missingness)
## Multiple R-squared:  0.1731, Adjusted R-squared:  0.1688 
## F-statistic: 40.25 on 6 and 1154 DF,  p-value: < 2.2e-16
## 
## 
## Teststatistic: -20.2252 
## Critical values: 0.01= -5.57 0.05= -5.08 0.1= -4.82 
## 
## Potential break point at position: 752

Andrews and Zivot Test Shows that before differencing both the series aren’t stationary. But after differencing both are stationary. Decision is done after looking on the test statistics with critical p values at one parcentage level of significance. Therefore, FundRate and MoodyBond are I(1).

Fund_Moody <- ca.jo(TwoSeries, ecdet="const", type="trace", K=2, spec="transitory")
summary(Fund_Moody)
## 
## ###################### 
## # Johansen-Procedure # 
## ###################### 
## 
## Test type: trace statistic , without linear trend and constant in cointegration 
## 
## Eigenvalues (lambda):
## [1] 7.062810e-02 6.142259e-03 3.423146e-19
## 
## Values of teststatistic and critical values of test:
## 
##           test 10pct  5pct  1pct
## r <= 1 |  3.39  7.52  9.24 12.97
## r = 0  | 43.75 17.85 19.96 24.60
## 
## Eigenvectors, normalised to first column:
## (These are the cointegration relations)
## 
##              FundRate.l1 MoodyBond.l1  constant
## FundRate.l1      1.00000      1.00000  1.000000
## MoodyBond.l1    -1.32546    -18.86278 -6.852696
## constant         4.78647    128.81160 96.685391
## 
## Weights W:
## (This is the loading matrix)
## 
##             FundRate.l1 MoodyBond.l1      constant
## FundRate.d  -0.04594305 0.0006790001 -4.526863e-19
## MoodyBond.d  0.02021882 0.0003156158  3.987170e-19
Fund_Moody <- ca.jo(TwoSeries, ecdet="const", type="eigen", K=2, spec="transitory")
summary(Fund_Moody)
## 
## ###################### 
## # Johansen-Procedure # 
## ###################### 
## 
## Test type: maximal eigenvalue statistic (lambda max) , without linear trend and constant in cointegration 
## 
## Eigenvalues (lambda):
## [1] 7.062810e-02 6.142259e-03 3.423146e-19
## 
## Values of teststatistic and critical values of test:
## 
##           test 10pct  5pct  1pct
## r <= 1 |  3.39  7.52  9.24 12.97
## r = 0  | 40.36 13.75 15.67 20.20
## 
## Eigenvectors, normalised to first column:
## (These are the cointegration relations)
## 
##              FundRate.l1 MoodyBond.l1  constant
## FundRate.l1      1.00000      1.00000  1.000000
## MoodyBond.l1    -1.32546    -18.86278 -6.852696
## constant         4.78647    128.81160 96.685391
## 
## Weights W:
## (This is the loading matrix)
## 
##             FundRate.l1 MoodyBond.l1      constant
## FundRate.d  -0.04594305 0.0006790001 -4.526863e-19
## MoodyBond.d  0.02021882 0.0003156158  3.987170e-19
lttest(Fund_Moody, 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.26    0.61
rest.beta2 <- matrix(c(0,-1,0,
                        0,0,1), c(3,2))
rbeta2 <- blrtest(Fund_Moody, H=rest.beta2, r=1)
summary(rbeta2)
## 
## ###################### 
## # 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:
## 36.91 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]
## FundRate.d   NaN  NaN
## MoodyBond.d  NaN  NaN
plotres(Fund_Moody)