library (Quandl)
## Loading required package: xts
## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
library(zoo)
library(xts)
library(dygraphs)
library(knitr)
library(forecast)
library(tseries)
library(urca)
Quandl.api_key('CEFP3eWxEJwr_uUP9a2D')
RPCE <- Quandl("FRED/A794RX0Q048SBEA", type="ts")
Original Time Series Graph
plot(RPCE, xlab=" Years", ylab="", main="Log Real personal consumption expenditures per capita" )
Log-transformed index Graph
l.RPCE <- log(RPCE)
plot(l.RPCE, xlab=" Years", ylab="", main="Real personal consumption expenditures per capita" )
Original and Log-transformed time series grows steadily and shows increasing variability over time.
dl.RPCE <- 100*diff(l.RPCE,lag=1)
plot(dl.RPCE, xlab=" Years", ylab="", main="Diff Log Real personal consumption expenditures per capita" )
adf.test(l.RPCE)
##
## Augmented Dickey-Fuller Test
##
## data: l.RPCE
## Dickey-Fuller = -1.169, Lag order = 6, p-value = 0.91
## alternative hypothesis: stationary
By ADF test we cannot reject the null hypothesis that the time series has a unit root.
kpss.test(l.RPCE, null="Trend")
## Warning in kpss.test(l.RPCE, null = "Trend"): p-value smaller than printed
## p-value
##
## KPSS Test for Trend Stationarity
##
## data: l.RPCE
## KPSS Trend = 0.75764, Truncation lag parameter = 3, p-value = 0.01
lRPCE.urkpss <- ur.kpss(l.RPCE, type="tau", lags="short")
summary(lRPCE.urkpss)
##
## #######################
## # KPSS Unit Root Test #
## #######################
##
## Test is of type: tau with 5 lags.
##
## Value of test-statistic is: 0.5183
##
## Critical value for a significance level of:
## 10pct 5pct 2.5pct 1pct
## critical values 0.119 0.146 0.176 0.216
By KPSS test we reject the null hypothesis that the time series is stationary.
lRPCE.urers1 <- ur.ers(l.RPCE, type="P-test", model="trend")
summary(lRPCE.urers1)
##
## ###############################################
## # Elliot, Rothenberg and Stock Unit Root Test #
## ###############################################
##
## Test of type P-test
## detrending of series with intercept and trend
##
## Value of test-statistic is: 10.5264
##
## Critical values of P-test are:
## 1pct 5pct 10pct
## critical values 3.96 5.62 6.89
lRPCE.urers2 <- ur.ers(l.RPCE, type="DF-GLS", model="trend")
summary(lRPCE.urers2)
##
## ###############################################
## # Elliot, Rothenberg and Stock Unit Root Test #
## ###############################################
##
## Test of type DF-GLS
## detrending of series with intercept and trend
##
##
## Call:
## lm(formula = dfgls.form, data = data.dfgls)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.044935 -0.003521 0.000139 0.004139 0.035773
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## yd.lag -0.01701 0.01027 -1.656 0.0988 .
## yd.diff.lag1 0.06119 0.05988 1.022 0.3078
## yd.diff.lag2 0.37417 0.05976 6.261 1.49e-09 ***
## yd.diff.lag3 0.03304 0.06034 0.548 0.5845
## yd.diff.lag4 -0.13376 0.06018 -2.223 0.0271 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.007614 on 271 degrees of freedom
## Multiple R-squared: 0.1397, Adjusted R-squared: 0.1238
## F-statistic: 8.802 on 5 and 271 DF, p-value: 9.37e-08
##
##
## Value of test-statistic is: -1.6562
##
## Critical values of DF-GLS are:
## 1pct 5pct 10pct
## critical values -3.48 -2.89 -2.57
Both ERS tests (P-test and DF-GLS test) suggest that our time series is not stationary.
Now we perform ADF, KPSS and ERS tests for the Real personal consumption expenditures per capita in first differences.
adf.test(dl.RPCE)
## Warning in adf.test(dl.RPCE): p-value smaller than printed p-value
##
## Augmented Dickey-Fuller Test
##
## data: dl.RPCE
## Dickey-Fuller = -5.7979, Lag order = 6, p-value = 0.01
## alternative hypothesis: stationary
kpss.test(dl.RPCE, null="Level")
## Warning in kpss.test(dl.RPCE, null = "Level"): p-value greater than printed
## p-value
##
## KPSS Test for Level Stationarity
##
## data: dl.RPCE
## KPSS Level = 0.17227, Truncation lag parameter = 3, p-value = 0.1
lRPCE.urkpss <- ur.kpss(dl.RPCE, type="tau", lags="short")
summary(lRPCE.urkpss)
##
## #######################
## # KPSS Unit Root Test #
## #######################
##
## Test is of type: tau with 5 lags.
##
## Value of test-statistic is: 0.0878
##
## Critical value for a significance level of:
## 10pct 5pct 2.5pct 1pct
## critical values 0.119 0.146 0.176 0.216
dlRPCE.urers1 <- ur.ers(dl.RPCE, type="P-test", model="trend")
summary(dlRPCE.urers1)
##
## ###############################################
## # 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.747
##
## Critical values of P-test are:
## 1pct 5pct 10pct
## critical values 3.96 5.62 6.89
dlRPCE.urers2 <- ur.ers(dl.RPCE, type="DF-GLS", model="trend")
summary(dlRPCE.urers2)
##
## ###############################################
## # Elliot, Rothenberg and Stock Unit Root Test #
## ###############################################
##
## Test of type DF-GLS
## detrending of series with intercept and trend
##
##
## Call:
## lm(formula = dfgls.form, data = data.dfgls)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.9583 -0.3908 0.0216 0.3550 3.2568
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## yd.lag -0.55507 0.09130 -6.080 4.09e-09 ***
## yd.diff.lag1 -0.35260 0.08819 -3.998 8.24e-05 ***
## yd.diff.lag2 0.04955 0.08623 0.575 0.566
## yd.diff.lag3 0.09053 0.08093 1.119 0.264
## yd.diff.lag4 -0.03140 0.06027 -0.521 0.603
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.7791 on 270 degrees of freedom
## Multiple R-squared: 0.5073, Adjusted R-squared: 0.4982
## F-statistic: 55.6 on 5 and 270 DF, p-value: < 2.2e-16
##
##
## Value of test-statistic is: -6.0799
##
## Critical values of DF-GLS are:
## 1pct 5pct 10pct
## critical values -3.48 -2.89 -2.57
All tests confirm that first difference logarithmic Real personal consumption expenditures per capita is stationary.
SNP.all <- Quandl("YAHOO/INDEX_GSPC", type="zoo")
SNP <- ts(SNP.all$Close)
l.SNP <- log(SNP)
plot(SNP, xlab=" Years", ylab="", main="S&P 500 Index" )
plot(l.SNP, xlab="Years", ylab="", main="Log S&P 500 Index" )
dl.SNP <- 100*diff(l.SNP,lag=1)
plot(dl.SNP, xlab=" 1950-2017", ylab="", main="Diff of Log S&P 500 Index" )
adf.test(l.SNP)
##
## Augmented Dickey-Fuller Test
##
## data: l.SNP
## Dickey-Fuller = -2.2359, Lag order = 25, p-value = 0.4784
## alternative hypothesis: stationary
ADF test shoes that we cannot reject the null hypothesis that the time series has a unit root.
kpss.test(l.SNP, null="Trend")
## Warning in kpss.test(l.SNP, null = "Trend"): p-value smaller than printed
## p-value
##
## KPSS Test for Trend Stationarity
##
## data: l.SNP
## KPSS Trend = 4.2602, Truncation lag parameter = 30, p-value = 0.01
lSNP.urkpss <- ur.kpss(l.SNP, type="tau", lags="short")
summary(lSNP.urkpss)
##
## #######################
## # KPSS Unit Root Test #
## #######################
##
## Test is of type: tau with 14 lags.
##
## Value of test-statistic is: 8.7771
##
## Critical value for a significance level of:
## 10pct 5pct 2.5pct 1pct
## critical values 0.119 0.146 0.176 0.216
KPSS test suggests to reject the null hypothesis that the time series is stationary.
lSNP.urers1 <- ur.ers(l.SNP, type="P-test", model="trend")
summary(lSNP.urers1)
##
## ###############################################
## # 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.9736
##
## Critical values of P-test are:
## 1pct 5pct 10pct
## critical values 3.96 5.62 6.89
lSNP.urers2 <- ur.ers(l.SNP, type="DF-GLS", model="trend")
summary(lSNP.urers2)
##
## ###############################################
## # Elliot, Rothenberg and Stock Unit Root Test #
## ###############################################
##
## Test of type DF-GLS
## detrending of series with intercept and trend
##
##
## Call:
## lm(formula = dfgls.form, data = data.dfgls)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.228557 -0.004316 0.000253 0.004710 0.105621
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## yd.lag -0.0004540 0.0002344 -1.937 0.052814 .
## yd.diff.lag1 0.0286647 0.0076852 3.730 0.000192 ***
## yd.diff.lag2 -0.0422727 0.0076883 -5.498 3.89e-08 ***
## yd.diff.lag3 0.0031772 0.0076882 0.413 0.679427
## yd.diff.lag4 -0.0081289 0.0076849 -1.058 0.290176
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.009673 on 16930 degrees of freedom
## Multiple R-squared: 0.002805, Adjusted R-squared: 0.00251
## F-statistic: 9.524 on 5 and 16930 DF, p-value: 4.375e-09
##
##
## Value of test-statistic is: -1.9366
##
## Critical values of DF-GLS are:
## 1pct 5pct 10pct
## critical values -3.48 -2.89 -2.57
According to ERS tests our time series is not stationary.
adf.test(dl.SNP)
## Warning in adf.test(dl.SNP): p-value smaller than printed p-value
##
## Augmented Dickey-Fuller Test
##
## data: dl.SNP
## Dickey-Fuller = -26.454, Lag order = 25, p-value = 0.01
## alternative hypothesis: stationary
kpss.test(dl.SNP, null="Level")
## Warning in kpss.test(dl.SNP, null = "Level"): p-value greater than printed
## p-value
##
## KPSS Test for Level Stationarity
##
## data: dl.SNP
## KPSS Level = 0.070918, Truncation lag parameter = 30, p-value =
## 0.1
lSNP.urkpss <- ur.kpss(dl.SNP, type="tau", lags="short")
summary(lSNP.urkpss)
##
## #######################
## # KPSS Unit Root Test #
## #######################
##
## Test is of type: tau with 14 lags.
##
## Value of test-statistic is: 0.0653
##
## Critical value for a significance level of:
## 10pct 5pct 2.5pct 1pct
## critical values 0.119 0.146 0.176 0.216
dlSNP.urers1 <- ur.ers(dl.SNP, type="P-test", model="trend")
summary(dlSNP.urers1)
##
## ###############################################
## # 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.0132
##
## Critical values of P-test are:
## 1pct 5pct 10pct
## critical values 3.96 5.62 6.89
dlSNP.urers2 <- ur.ers(dl.SNP, type="DF-GLS", model="trend")
summary(dlSNP.urers2)
##
## ###############################################
## # Elliot, Rothenberg and Stock Unit Root Test #
## ###############################################
##
## Test of type DF-GLS
## detrending of series with intercept and trend
##
##
## Call:
## lm(formula = dfgls.form, data = data.dfgls)
##
## Residuals:
## Min 1Q Median 3Q Max
## -21.6921 -0.6338 -0.1500 0.3615 13.1977
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## yd.lag -0.393329 0.011314 -34.76 <2e-16 ***
## yd.diff.lag1 -0.448796 0.011593 -38.71 <2e-16 ***
## yd.diff.lag2 -0.366503 0.011095 -33.03 <2e-16 ***
## yd.diff.lag3 -0.233428 0.009846 -23.71 <2e-16 ***
## yd.diff.lag4 -0.116634 0.007633 -15.28 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.029 on 16929 degrees of freedom
## Multiple R-squared: 0.4202, Adjusted R-squared: 0.42
## F-statistic: 2454 on 5 and 16929 DF, p-value: < 2.2e-16
##
##
## Value of test-statistic is: -34.7644
##
## Critical values of DF-GLS are:
## 1pct 5pct 10pct
## critical values -3.48 -2.89 -2.57
S&P 500 Index is stationary according to all the tests.
Gross Domestic Product: Implicit Price Deflator
IPD <- Quandl("FRED/GDPDEF", type="ts")
We are going to plot the original and log-transformed GDP : Implicit Price Deflator.
plot(IPD, xlab="Years", ylab="", main="GDP : Implicit Price Deflator" )
l.IPD <- log(IPD)
plot(l.IPD, xlab=" Years", ylab="", main="Log GDP : Implicit Price Deflator" )
dl.IPD <- 100*diff(l.IPD,lag=1)
plot(dl.IPD, xlab="Years", ylab="", main="Diff Log GDP : Implicit Price Deflator" )
adf.test(l.IPD)
##
## Augmented Dickey-Fuller Test
##
## data: l.IPD
## Dickey-Fuller = -1.0433, Lag order = 6, p-value = 0.9303
## alternative hypothesis: stationary
ADF test shows that we cannot reject the null hypothesis that the time series has a unit root.
kpss.test(l.IPD, null="Trend")
## Warning in kpss.test(l.IPD, null = "Trend"): p-value smaller than printed
## p-value
##
## KPSS Test for Trend Stationarity
##
## data: l.IPD
## KPSS Trend = 0.98785, Truncation lag parameter = 3, p-value = 0.01
lIPD.urkpss <- ur.kpss(l.IPD, type="tau", lags="short")
summary(lIPD.urkpss)
##
## #######################
## # KPSS Unit Root Test #
## #######################
##
## Test is of type: tau with 5 lags.
##
## Value of test-statistic is: 0.6633
##
## Critical value for a significance level of:
## 10pct 5pct 2.5pct 1pct
## critical values 0.119 0.146 0.176 0.216
KPSS test shows that we reject the null hypothesis that the time series is stationary.
lIPD.urers1 <- ur.ers(l.IPD, type="P-test", model="trend")
summary(lIPD.urers1)
##
## ###############################################
## # Elliot, Rothenberg and Stock Unit Root Test #
## ###############################################
##
## Test of type P-test
## detrending of series with intercept and trend
##
## Value of test-statistic is: 30.7793
##
## Critical values of P-test are:
## 1pct 5pct 10pct
## critical values 3.96 5.62 6.89
lIPD.urers2 <- ur.ers(l.IPD, type="DF-GLS", model="trend")
summary(lIPD.urers2)
##
## ###############################################
## # Elliot, Rothenberg and Stock Unit Root Test #
## ###############################################
##
## Test of type DF-GLS
## detrending of series with intercept and trend
##
##
## Call:
## lm(formula = dfgls.form, data = data.dfgls)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.0213074 -0.0017538 -0.0003115 0.0013199 0.0192671
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## yd.lag -0.001905 0.001645 -1.158 0.2480
## yd.diff.lag1 0.585564 0.059548 9.834 <2e-16 ***
## yd.diff.lag2 0.153612 0.066944 2.295 0.0225 *
## yd.diff.lag3 0.153397 0.067009 2.289 0.0228 *
## yd.diff.lag4 -0.040672 0.058979 -0.690 0.4910
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.003752 on 271 degrees of freedom
## Multiple R-squared: 0.6418, Adjusted R-squared: 0.6352
## F-statistic: 97.12 on 5 and 271 DF, p-value: < 2.2e-16
##
##
## Value of test-statistic is: -1.1578
##
## Critical values of DF-GLS are:
## 1pct 5pct 10pct
## critical values -3.48 -2.89 -2.57
Both ERS tests shows that our time series is not stationary.
adf.test(dl.IPD)
##
## Augmented Dickey-Fuller Test
##
## data: dl.IPD
## Dickey-Fuller = -3.5512, Lag order = 6, p-value = 0.03824
## alternative hypothesis: stationary
kpss.test(dl.IPD, null="Level")
## Warning in kpss.test(dl.IPD, null = "Level"): p-value smaller than printed
## p-value
##
## KPSS Test for Level Stationarity
##
## data: dl.IPD
## KPSS Level = 0.9464, Truncation lag parameter = 3, p-value = 0.01
dl.IPD.urkpss <- ur.kpss(dl.IPD, type="tau", lags="short")
summary(dl.IPD.urkpss)
##
## #######################
## # KPSS Unit Root Test #
## #######################
##
## Test is of type: tau with 5 lags.
##
## Value of test-statistic is: 0.5093
##
## Critical value for a significance level of:
## 10pct 5pct 2.5pct 1pct
## critical values 0.119 0.146 0.176 0.216
dl.IPD.urers1 <- ur.ers(dl.IPD, type="P-test", model="trend")
summary(dl.IPD.urers1)
##
## ###############################################
## # Elliot, Rothenberg and Stock Unit Root Test #
## ###############################################
##
## Test of type P-test
## detrending of series with intercept and trend
##
## Value of test-statistic is: 3.3529
##
## Critical values of P-test are:
## 1pct 5pct 10pct
## critical values 3.96 5.62 6.89
dl.IPD.urers2 <- ur.ers(dl.IPD, type="DF-GLS", model="trend")
summary(dl.IPD.urers2)
##
## ###############################################
## # Elliot, Rothenberg and Stock Unit Root Test #
## ###############################################
##
## Test of type DF-GLS
## detrending of series with intercept and trend
##
##
## Call:
## lm(formula = dfgls.form, data = data.dfgls)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.25753 -0.17889 -0.02241 0.13887 1.82827
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## yd.lag -0.14755 0.03999 -3.690 0.000271 ***
## yd.diff.lag1 -0.26984 0.06514 -4.142 4.6e-05 ***
## yd.diff.lag2 -0.09394 0.06570 -1.430 0.153929
## yd.diff.lag3 0.06550 0.06404 1.023 0.307347
## yd.diff.lag4 0.04604 0.05905 0.780 0.436208
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.3767 on 270 degrees of freedom
## Multiple R-squared: 0.17, Adjusted R-squared: 0.1547
## F-statistic: 11.06 on 5 and 270 DF, p-value: 1.045e-09
##
##
## Value of test-statistic is: -3.6898
##
## Critical values of DF-GLS are:
## 1pct 5pct 10pct
## critical values -3.48 -2.89 -2.57
All tests confirm that the first difference log of GDP Implicit Price Deflator is stationary.
10-Year Treasury with wConstant Maturity Rate
TYTSMR <- Quandl("FRED/DGS10", type="zoo")
plot(TYTSMR, xlab="Years", ylab="", main="10-Year Treasury with Constant Maturity Rate" )
l.TYTSMR <- log(TYTSMR)
plot(l.TYTSMR, xlab="Years", ylab="", main="Log 10-Year Treasury with Constant Maturity Rate" )
d.TYTSMR <- 100*diff(TYTSMR,lag=1)
plot(d.TYTSMR, xlab="Years", ylab="", main="Diff Log 10-Year Treasury with Constant Maturity Rate" )
adf.test(TYTSMR)
##
## Augmented Dickey-Fuller Test
##
## data: TYTSMR
## Dickey-Fuller = -2.1993, Lag order = 23, p-value = 0.4939
## alternative hypothesis: stationary
ADF test shows us that we cannot reject the null hypothesis that the time series has a unit root.
kpss.test(TYTSMR, null="Trend")
## Warning in kpss.test(TYTSMR, null = "Trend"): p-value smaller than printed
## p-value
##
## KPSS Test for Trend Stationarity
##
## data: TYTSMR
## KPSS Trend = 9.0346, Truncation lag parameter = 27, p-value = 0.01
TYTSMR.urkpss <- ur.kpss(TYTSMR, type="tau", lags="short")
summary(TYTSMR.urkpss)
##
## #######################
## # KPSS Unit Root Test #
## #######################
##
## Test is of type: tau with 13 lags.
##
## Value of test-statistic is: 18.0225
##
## Critical value for a significance level of:
## 10pct 5pct 2.5pct 1pct
## critical values 0.119 0.146 0.176 0.216
KPSS test shows us that we will reject the null hypothesis that the time series is stationary.
TYTSMR.urers1 <- ur.ers(TYTSMR, type="P-test", model="trend")
summary(TYTSMR.urers1)
##
## ###############################################
## # Elliot, Rothenberg and Stock Unit Root Test #
## ###############################################
##
## Test of type P-test
## detrending of series with intercept and trend
##
## Value of test-statistic is: 32.3186
##
## Critical values of P-test are:
## 1pct 5pct 10pct
## critical values 3.96 5.62 6.89
TYTSMR.urers2 <- ur.ers(TYTSMR, type="DF-GLS", model="trend")
summary(TYTSMR.urers2)
##
## ###############################################
## # Elliot, Rothenberg and Stock Unit Root Test #
## ###############################################
##
## Test of type DF-GLS
## detrending of series with intercept and trend
##
##
## Call:
## lm(formula = dfgls.form, data = data.dfgls)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.74002 -0.02917 -0.00002 0.02896 0.63769
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## yd.lag -0.0001711 0.0001657 -1.033 0.3018
## yd.diff.lag1 0.0692932 0.0085098 8.143 4.19e-16 ***
## yd.diff.lag2 0.0117515 0.0085302 1.378 0.1683
## yd.diff.lag3 -0.0006357 0.0085304 -0.075 0.9406
## yd.diff.lag4 -0.0181333 0.0085102 -2.131 0.0331 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.06622 on 13805 degrees of freedom
## Multiple R-squared: 0.00544, Adjusted R-squared: 0.00508
## F-statistic: 15.1 on 5 and 13805 DF, p-value: 8.01e-15
##
##
## Value of test-statistic is: -1.0326
##
## Critical values of DF-GLS are:
## 1pct 5pct 10pct
## critical values -3.48 -2.89 -2.57
Both ERS tests suggest that our time series is not stationary.
adf.test(d.TYTSMR)
## Warning in adf.test(d.TYTSMR): p-value smaller than printed p-value
##
## Augmented Dickey-Fuller Test
##
## data: d.TYTSMR
## Dickey-Fuller = -22.406, Lag order = 23, p-value = 0.01
## alternative hypothesis: stationary
kpss.test(d.TYTSMR, null="Level")
## Warning in kpss.test(d.TYTSMR, null = "Level"): p-value greater than
## printed p-value
##
## KPSS Test for Level Stationarity
##
## data: d.TYTSMR
## KPSS Level = 0.20953, Truncation lag parameter = 27, p-value = 0.1
d.TYTSMR.urkpss <- ur.kpss(d.TYTSMR, type="tau", lags="short")
summary(d.TYTSMR.urkpss)
##
## #######################
## # KPSS Unit Root Test #
## #######################
##
## Test is of type: tau with 13 lags.
##
## Value of test-statistic is: 0.0469
##
## Critical value for a significance level of:
## 10pct 5pct 2.5pct 1pct
## critical values 0.119 0.146 0.176 0.216
d.TYTSMR.urers1 <- ur.ers(d.TYTSMR, type="P-test", model="trend")
summary(d.TYTSMR.urers1)
##
## ###############################################
## # 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.0158
##
## Critical values of P-test are:
## 1pct 5pct 10pct
## critical values 3.96 5.62 6.89
d.TYTSMR.urers2 <- ur.ers(d.TYTSMR, type="DF-GLS", model="trend")
summary(d.TYTSMR.urers2)
##
## ###############################################
## # Elliot, Rothenberg and Stock Unit Root Test #
## ###############################################
##
## Test of type DF-GLS
## detrending of series with intercept and trend
##
##
## Call:
## lm(formula = dfgls.form, data = data.dfgls)
##
## Residuals:
## Min 1Q Median 3Q Max
## -73.743 -2.333 1.149 3.707 62.830
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## yd.lag -0.726240 0.016274 -44.625 < 2e-16 ***
## yd.diff.lag1 -0.164396 0.014996 -10.963 < 2e-16 ***
## yd.diff.lag2 -0.116506 0.013400 -8.694 < 2e-16 ***
## yd.diff.lag3 -0.081771 0.011363 -7.197 6.49e-13 ***
## yd.diff.lag4 -0.065545 0.008493 -7.717 1.27e-14 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 6.747 on 13804 degrees of freedom
## Multiple R-squared: 0.4449, Adjusted R-squared: 0.4447
## F-statistic: 2213 on 5 and 13804 DF, p-value: < 2.2e-16
##
##
## Value of test-statistic is: -44.6249
##
## Critical values of DF-GLS are:
## 1pct 5pct 10pct
## critical values -3.48 -2.89 -2.57
All tests confirm that the first difference of log 10-Year Treasury with Constant Maturity Rate is stationary.
Employment Population Ratio
EPR <- Quandl("FRED/EMRATIO", type="ts")
plot(EPR, xlab="Years", ylab="", main="EPR" )
l.EPR <- log(EPR)
plot(l.EPR, xlab="Years", ylab="", main="Log EPR" )
d.EPR <- 100*diff(EPR,lag=1)
plot(d.EPR, xlab="Years", ylab="", main="Diff Log EPR" )
adf.test(EPR)
##
## Augmented Dickey-Fuller Test
##
## data: EPR
## Dickey-Fuller = -2.4233, Lag order = 9, p-value = 0.3991
## alternative hypothesis: stationary
ADF test shows that we will not reject the null hypothesis that the time series has a unit root.
kpss.test(EPR, null="Trend")
## Warning in kpss.test(EPR, null = "Trend"): p-value smaller than printed p-
## value
##
## KPSS Test for Trend Stationarity
##
## data: EPR
## KPSS Trend = 1.2292, Truncation lag parameter = 6, p-value = 0.01
EPR.urkpss <- ur.kpss(EPR, type="tau", lags="short")
summary(EPR.urkpss)
##
## #######################
## # KPSS Unit Root Test #
## #######################
##
## Test is of type: tau with 6 lags.
##
## Value of test-statistic is: 1.2292
##
## Critical value for a significance level of:
## 10pct 5pct 2.5pct 1pct
## critical values 0.119 0.146 0.176 0.216
KPSS test shows that we’d reject the null hypothesis that the time series is stationary.
EPR.urers1 <- ur.ers(EPR, type="P-test", model="trend")
summary(EPR.urers1)
##
## ###############################################
## # Elliot, Rothenberg and Stock Unit Root Test #
## ###############################################
##
## Test of type P-test
## detrending of series with intercept and trend
##
## Value of test-statistic is: 12.5701
##
## Critical values of P-test are:
## 1pct 5pct 10pct
## critical values 3.96 5.62 6.89
EPR.urers2 <- ur.ers(EPR, type="DF-GLS", model="trend")
summary(EPR.urers2)
##
## ###############################################
## # Elliot, Rothenberg and Stock Unit Root Test #
## ###############################################
##
## Test of type DF-GLS
## detrending of series with intercept and trend
##
##
## Call:
## lm(formula = dfgls.form, data = data.dfgls)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.78175 -0.10833 0.00144 0.11638 0.80890
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## yd.lag -0.006589 0.003534 -1.864 0.062610 .
## yd.diff.lag1 -0.141486 0.034532 -4.097 4.60e-05 ***
## yd.diff.lag2 0.132831 0.034452 3.855 0.000125 ***
## yd.diff.lag3 0.146381 0.034386 4.257 2.31e-05 ***
## yd.diff.lag4 0.127873 0.034288 3.729 0.000205 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.1994 on 821 degrees of freedom
## Multiple R-squared: 0.06848, Adjusted R-squared: 0.06281
## F-statistic: 12.07 on 5 and 821 DF, p-value: 2.666e-11
##
##
## Value of test-statistic is: -1.8645
##
## Critical values of DF-GLS are:
## 1pct 5pct 10pct
## critical values -3.48 -2.89 -2.57
Both ERS tests suggest that our time series is not stationary.
adf.test(d.EPR)
## Warning in adf.test(d.EPR): p-value smaller than printed p-value
##
## Augmented Dickey-Fuller Test
##
## data: d.EPR
## Dickey-Fuller = -6.926, Lag order = 9, p-value = 0.01
## alternative hypothesis: stationary
kpss.test(d.EPR, null="Level")
## Warning in kpss.test(d.EPR, null = "Level"): p-value greater than printed
## p-value
##
## KPSS Test for Level Stationarity
##
## data: d.EPR
## KPSS Level = 0.12379, Truncation lag parameter = 6, p-value = 0.1
d.EPR.urkpss <- ur.kpss(d.EPR, type="tau", lags="short")
summary(d.EPR.urkpss)
##
## #######################
## # KPSS Unit Root Test #
## #######################
##
## Test is of type: tau with 6 lags.
##
## Value of test-statistic is: 0.098
##
## Critical value for a significance level of:
## 10pct 5pct 2.5pct 1pct
## critical values 0.119 0.146 0.176 0.216
d.EPR.urers1 <- ur.ers(d.EPR, type="P-test", model="trend")
summary(d.EPR.urers1)
##
## ###############################################
## # Elliot, Rothenberg and Stock Unit Root Test #
## ###############################################
##
## Test of type P-test
## detrending of series with intercept and trend
##
## Value of test-statistic is: 1.2622
##
## Critical values of P-test are:
## 1pct 5pct 10pct
## critical values 3.96 5.62 6.89
d.EPR.urers2 <- ur.ers(d.EPR, type="DF-GLS", model="trend")
summary(d.EPR.urers2)
##
## ###############################################
## # Elliot, Rothenberg and Stock Unit Root Test #
## ###############################################
##
## Test of type DF-GLS
## detrending of series with intercept and trend
##
##
## Call:
## lm(formula = dfgls.form, data = data.dfgls)
##
## Residuals:
## Min 1Q Median 3Q Max
## -81.932 -12.614 -1.301 9.992 82.680
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## yd.lag -0.54673 0.06602 -8.282 4.91e-16 ***
## yd.diff.lag1 -0.58224 0.06354 -9.163 < 2e-16 ***
## yd.diff.lag2 -0.45006 0.05995 -7.508 1.57e-13 ***
## yd.diff.lag3 -0.28528 0.05123 -5.568 3.48e-08 ***
## yd.diff.lag4 -0.11873 0.03405 -3.487 0.000515 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 19.92 on 820 degrees of freedom
## Multiple R-squared: 0.5816, Adjusted R-squared: 0.579
## F-statistic: 228 on 5 and 820 DF, p-value: < 2.2e-16
##
##
## Value of test-statistic is: -8.2818
##
## Critical values of DF-GLS are:
## 1pct 5pct 10pct
## critical values -3.48 -2.89 -2.57
All tests confirm that the first difference log EPR is stationary.
U.S. / U.K. Foreign Exchange Rate
EXUSUK <- Quandl("FRED/EXUSUK", type="ts")
plot(EXUSUK, xlab=" Years", ylab="", main="U.S. / U.K. FER" )
l.EXUSUK <- log(EXUSUK)
plot(l.EXUSUK, xlab=" Years", ylab="", main="U.S. / U.K. FER" )
d.EXUSUK <- 100*diff(EXUSUK,lag=1)
plot(d.EXUSUK, xlab="Years", ylab="", main="Diff Log U.S. / U.K. FER" )
adf.test(EXUSUK)
##
## Augmented Dickey-Fuller Test
##
## data: EXUSUK
## Dickey-Fuller = -2.8386, Lag order = 8, p-value = 0.2233
## alternative hypothesis: stationary
ADF test shows that we cannot reject the null hypothesis that the time series has a unit root.
kpss.test(EXUSUK, null="Trend")
## Warning in kpss.test(EXUSUK, null = "Trend"): p-value smaller than printed
## p-value
##
## KPSS Test for Trend Stationarity
##
## data: EXUSUK
## KPSS Trend = 0.88408, Truncation lag parameter = 5, p-value = 0.01
EXUSUK.urkpss <- ur.kpss(EXUSUK, type="tau", lags="short")
summary(EXUSUK.urkpss)
##
## #######################
## # KPSS Unit Root Test #
## #######################
##
## Test is of type: tau with 6 lags.
##
## Value of test-statistic is: 0.7648
##
## Critical value for a significance level of:
## 10pct 5pct 2.5pct 1pct
## critical values 0.119 0.146 0.176 0.216
KPSS test shows that we will reject the null hypothesis that the time series is stationary.
EXUSUK.urers1 <- ur.ers(EXUSUK, type="P-test", model="trend")
summary(EXUSUK.urers1)
##
## ###############################################
## # 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.4934
##
## Critical values of P-test are:
## 1pct 5pct 10pct
## critical values 3.96 5.62 6.89
EXUSUK.urers2 <- ur.ers(EXUSUK, type="DF-GLS", model="trend")
summary(EXUSUK.urers2)
##
## ###############################################
## # Elliot, Rothenberg and Stock Unit Root Test #
## ###############################################
##
## Test of type DF-GLS
## detrending of series with intercept and trend
##
##
## Call:
## lm(formula = dfgls.form, data = data.dfgls)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.155650 -0.023298 -0.000354 0.024026 0.121032
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## yd.lag -0.012440 0.005427 -2.292 0.02226 *
## yd.diff.lag1 0.409620 0.042626 9.610 < 2e-16 ***
## yd.diff.lag2 -0.135449 0.045930 -2.949 0.00332 **
## yd.diff.lag3 0.108469 0.045874 2.365 0.01840 *
## yd.diff.lag4 -0.011065 0.042837 -0.258 0.79627
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.03818 on 546 degrees of freedom
## Multiple R-squared: 0.1538, Adjusted R-squared: 0.146
## F-statistic: 19.85 on 5 and 546 DF, p-value: < 2.2e-16
##
##
## Value of test-statistic is: -2.2924
##
## Critical values of DF-GLS are:
## 1pct 5pct 10pct
## critical values -3.48 -2.89 -2.57
Both ERS tests suggest that our time series is not stationary.
adf.test(d.EXUSUK)
## Warning in adf.test(d.EXUSUK): p-value smaller than printed p-value
##
## Augmented Dickey-Fuller Test
##
## data: d.EXUSUK
## Dickey-Fuller = -7.6658, Lag order = 8, p-value = 0.01
## alternative hypothesis: stationary
kpss.test(d.EXUSUK, null="Level")
## Warning in kpss.test(d.EXUSUK, null = "Level"): p-value greater than
## printed p-value
##
## KPSS Test for Level Stationarity
##
## data: d.EXUSUK
## KPSS Level = 0.059692, Truncation lag parameter = 5, p-value = 0.1
d.EXUSUK.urkpss <- ur.kpss(d.EXUSUK, type="tau", lags="short")
summary(d.EXUSUK.urkpss)
##
## #######################
## # KPSS Unit Root Test #
## #######################
##
## Test is of type: tau with 6 lags.
##
## Value of test-statistic is: 0.05
##
## Critical value for a significance level of:
## 10pct 5pct 2.5pct 1pct
## critical values 0.119 0.146 0.176 0.216
d.EXUSUK.urers1 <- ur.ers(d.EXUSUK, type="P-test", model="trend")
summary(d.EXUSUK.urers1)
##
## ###############################################
## # 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.4452
##
## Critical values of P-test are:
## 1pct 5pct 10pct
## critical values 3.96 5.62 6.89
d.EXUSUK.urers2 <- ur.ers(d.EXUSUK, type="DF-GLS", model="trend")
summary(d.EXUSUK.urers2)
##
## ###############################################
## # Elliot, Rothenberg and Stock Unit Root Test #
## ###############################################
##
## Test of type DF-GLS
## detrending of series with intercept and trend
##
##
## Call:
## lm(formula = dfgls.form, data = data.dfgls)
##
## Residuals:
## Min 1Q Median 3Q Max
## -15.7951 -2.5567 -0.3266 2.1186 11.4357
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## yd.lag -0.61916 0.06622 -9.350 <2e-16 ***
## yd.diff.lag1 0.04066 0.06330 0.642 0.521
## yd.diff.lag2 -0.08909 0.05793 -1.538 0.125
## yd.diff.lag3 0.02120 0.04948 0.428 0.669
## yd.diff.lag4 0.02648 0.04287 0.618 0.537
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 3.867 on 545 degrees of freedom
## Multiple R-squared: 0.3246, Adjusted R-squared: 0.3184
## F-statistic: 52.38 on 5 and 545 DF, p-value: < 2.2e-16
##
##
## Value of test-statistic is: -9.3504
##
## Critical values of DF-GLS are:
## 1pct 5pct 10pct
## critical values -3.48 -2.89 -2.57
All tests confirm that the first difference U.S. / U.K. Foreign Exchange Rate is stationary.