Obtain quarterly time series for Disposable Personal Income FRED/DPI and for Personal Consumption Expenditures FRED/PCEC.
Importing the data from Quand:
DPI <- Quandl("FRED/DPI", type="ts")
PCEC <- Quandl("FRED/PCEC", type="ts")
y1t <- log(PCEC)
y2t <- log(DPI)
par(mfrow=c(2,2), cex=0.5, mar=c(2,2,3,1))
plot(PCEC, xlab="", ylab="", main="PCEC")
plot(y1t, xlab="", ylab="", main="Log PCEC")
plot(DPI, xlab="", ylab="", main="DPI")
plot(y2t, xlab="", ylab="", main="Log DPI")
Unit root test for \(y_{1,t}\) and \(y_{2,t}\):
summary( ur.df(y1t, lags=12, selectlags="AIC", type="trend") )
###############################################
# Augmented Dickey-Fuller Test Unit Root Test #
###############################################
Test regression trend
Call:
lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)
Residuals:
Min 1Q Median 3Q Max
-0.038492 -0.003690 0.000316 0.004449 0.052184
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.522e-02 1.735e-02 0.877 0.38133
z.lag.1 -2.037e-03 3.673e-03 -0.555 0.57956
tt 2.398e-05 6.618e-05 0.362 0.71738
z.diff.lag1 2.137e-02 6.239e-02 0.343 0.73225
z.diff.lag2 3.654e-01 6.166e-02 5.925 1.02e-08 ***
z.diff.lag3 1.909e-02 6.561e-02 0.291 0.77138
z.diff.lag4 -1.287e-01 6.563e-02 -1.961 0.05101 .
z.diff.lag5 8.795e-02 6.587e-02 1.335 0.18304
z.diff.lag6 2.814e-02 6.585e-02 0.427 0.66956
z.diff.lag7 7.763e-02 6.508e-02 1.193 0.23404
z.diff.lag8 -7.342e-03 6.524e-02 -0.113 0.91049
z.diff.lag9 1.583e-01 6.101e-02 2.594 0.01004 *
z.diff.lag10 1.627e-01 6.174e-02 2.636 0.00892 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.008196 on 251 degrees of freedom
Multiple R-squared: 0.322, Adjusted R-squared: 0.2896
F-statistic: 9.933 on 12 and 251 DF, p-value: 7.279e-16
Value of test-statistic is: -0.5547 2.3638 1.732
Critical values for test statistics:
1pct 5pct 10pct
tau3 -3.98 -3.42 -3.13
phi2 6.15 4.71 4.05
phi3 8.34 6.30 5.36
summary( ur.ers(y1t, type="P-test", lag.max=8, 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: 63.1974
Critical values of P-test are:
1pct 5pct 10pct
critical values 3.96 5.62 6.89
summary( ur.za(y1t, model="trend") )
################################
# Zivot-Andrews Unit Root Test #
################################
Call:
lm(formula = testmat)
Residuals:
Min 1Q Median 3Q Max
-0.035383 -0.004018 0.000108 0.004278 0.057514
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 7.533e-02 2.334e-02 3.227 0.00140 **
y.l1 9.873e-01 4.861e-03 203.118 < 2e-16 ***
trend 2.867e-04 9.557e-05 3.000 0.00295 **
dt -2.557e-04 3.980e-05 -6.425 5.88e-10 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.008852 on 272 degrees of freedom
(1 observation deleted due to missingness)
Multiple R-squared: 1, Adjusted R-squared: 1
F-statistic: 2.311e+06 on 3 and 272 DF, p-value: < 2.2e-16
Teststatistic: -2.6131
Critical values: 0.01= -4.93 0.05= -4.42 0.1= -4.11
Potential break point at position: 168
summary( ur.kpss(y1t, lags="short", type="tau") )
#######################
# KPSS Unit Root Test #
#######################
Test is of type: tau with 5 lags.
Value of test-statistic is: 0.7215
Critical value for a significance level of:
10pct 5pct 2.5pct 1pct
critical values 0.119 0.146 0.176 0.216
summary( ur.df(y2t, lags=12, selectlags="AIC", type="trend") )
###############################################
# Augmented Dickey-Fuller Test Unit Root Test #
###############################################
Test regression trend
Call:
lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)
Residuals:
Min 1Q Median 3Q Max
-0.049321 -0.004627 -0.000190 0.005317 0.032058
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.245e-02 1.939e-02 0.642 0.521325
z.lag.1 -1.324e-03 4.009e-03 -0.330 0.741445
tt 1.273e-05 7.184e-05 0.177 0.859496
z.diff.lag1 4.533e-02 5.778e-02 0.785 0.433464
z.diff.lag2 2.132e-01 5.765e-02 3.698 0.000267 ***
z.diff.lag3 1.041e-01 5.881e-02 1.771 0.077852 .
z.diff.lag4 2.747e-03 5.876e-02 0.047 0.962755
z.diff.lag5 5.558e-02 5.661e-02 0.982 0.327111
z.diff.lag6 6.028e-02 5.638e-02 1.069 0.285988
z.diff.lag7 2.204e-02 5.560e-02 0.396 0.692104
z.diff.lag8 -6.663e-04 5.504e-02 -0.012 0.990352
z.diff.lag9 4.879e-02 5.429e-02 0.899 0.369720
z.diff.lag10 1.736e-01 5.399e-02 3.216 0.001471 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.008831 on 251 degrees of freedom
Multiple R-squared: 0.228, Adjusted R-squared: 0.1911
F-statistic: 6.176 on 12 and 251 DF, p-value: 1.636e-09
Value of test-statistic is: -0.3303 2.1385 1.0011
Critical values for test statistics:
1pct 5pct 10pct
tau3 -3.98 -3.42 -3.13
phi2 6.15 4.71 4.05
phi3 8.34 6.30 5.36
summary( ur.ers(y2t, type="P-test", lag.max=8, 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: 83.7733
Critical values of P-test are:
1pct 5pct 10pct
critical values 3.96 5.62 6.89
summary( ur.za(y2t, model="trend") )
################################
# Zivot-Andrews Unit Root Test #
################################
Call:
lm(formula = testmat)
Residuals:
Min 1Q Median 3Q Max
-0.047478 -0.005133 -0.000862 0.004480 0.058134
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.0880249 0.0309434 2.845 0.00478 **
y.l1 0.9852704 0.0062780 156.941 < 2e-16 ***
trend 0.0003178 0.0001238 2.568 0.01078 *
dt -0.0002536 0.0000508 -4.992 1.07e-06 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.0103 on 272 degrees of freedom
(1 observation deleted due to missingness)
Multiple R-squared: 0.9999, Adjusted R-squared: 0.9999
F-statistic: 1.67e+06 on 3 and 272 DF, p-value: < 2.2e-16
Teststatistic: -2.3462
Critical values: 0.01= -4.93 0.05= -4.42 0.1= -4.11
Potential break point at position: 165
summary( ur.kpss(y2t, lags="short", type="tau") )
#######################
# KPSS Unit Root Test #
#######################
Test is of type: tau with 5 lags.
Value of test-statistic is: 0.7895
Critical value for a significance level of:
10pct 5pct 2.5pct 1pct
critical values 0.119 0.146 0.176 0.216
Both \(y_{1,t}\) and \(y_{2,t}\) contain unit-root, we need to differentiate the series and retest for unit root.
dy1t <- diff(y1t)
dy2t <- diff(y2t)
summary( ur.df(dy1t, lags=12, selectlags="AIC", type="trend") )
###############################################
# Augmented Dickey-Fuller Test Unit Root Test #
###############################################
Test regression trend
Call:
lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)
Residuals:
Min 1Q Median 3Q Max
-0.038405 -0.003635 0.000145 0.004388 0.052060
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 5.474e-03 2.195e-03 2.493 0.013296 *
z.lag.1 -2.380e-01 9.712e-02 -2.451 0.014927 *
tt -1.197e-05 7.115e-06 -1.683 0.093676 .
z.diff.lag1 -7.422e-01 1.053e-01 -7.049 1.74e-11 ***
z.diff.lag2 -3.786e-01 1.097e-01 -3.450 0.000656 ***
z.diff.lag3 -3.585e-01 1.069e-01 -3.354 0.000919 ***
z.diff.lag4 -4.903e-01 1.026e-01 -4.780 2.99e-06 ***
z.diff.lag5 -4.002e-01 9.934e-02 -4.028 7.46e-05 ***
z.diff.lag6 -3.720e-01 9.241e-02 -4.025 7.54e-05 ***
z.diff.lag7 -2.986e-01 8.845e-02 -3.375 0.000854 ***
z.diff.lag8 -3.106e-01 8.307e-02 -3.739 0.000229 ***
z.diff.lag9 -1.557e-01 6.125e-02 -2.543 0.011598 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.008196 on 251 degrees of freedom
Multiple R-squared: 0.5725, Adjusted R-squared: 0.5538
F-statistic: 30.56 on 11 and 251 DF, p-value: < 2.2e-16
Value of test-statistic is: -2.451 2.2788 3.4093
Critical values for test statistics:
1pct 5pct 10pct
tau3 -3.98 -3.42 -3.13
phi2 6.15 4.71 4.05
phi3 8.34 6.30 5.36
summary( ur.ers(dy1t, type="P-test", lag.max=8, 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: 1.7594
Critical values of P-test are:
1pct 5pct 10pct
critical values 3.96 5.62 6.89
summary( ur.za(dy1t, model="trend") )
################################
# Zivot-Andrews Unit Root Test #
################################
Call:
lm(formula = testmat)
Residuals:
Min 1Q Median 3Q Max
-0.035947 -0.003901 0.000282 0.004086 0.058706
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.073e-02 1.612e-03 6.658 1.54e-10 ***
y.l1 -1.184e-02 6.045e-02 -0.196 0.845
trend 1.081e-04 1.822e-05 5.932 9.10e-09 ***
dt -2.240e-04 2.974e-05 -7.535 7.34e-13 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.008584 on 271 degrees of freedom
(1 observation deleted due to missingness)
Multiple R-squared: 0.234, Adjusted R-squared: 0.2255
F-statistic: 27.59 on 3 and 271 DF, p-value: 1.33e-15
Teststatistic: -16.7375
Critical values: 0.01= -4.93 0.05= -4.42 0.1= -4.11
Potential break point at position: 122
summary( ur.kpss(dy1t, lags="short", type="tau") )
#######################
# KPSS Unit Root Test #
#######################
Test is of type: tau with 5 lags.
Value of test-statistic is: 0.6299
Critical value for a significance level of:
10pct 5pct 2.5pct 1pct
critical values 0.119 0.146 0.176 0.216
summary( ur.df(dy2t, lags=12, selectlags="AIC", type="trend") )
###############################################
# Augmented Dickey-Fuller Test Unit Root Test #
###############################################
Test regression trend
Call:
lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)
Residuals:
Min 1Q Median 3Q Max
-0.049827 -0.004490 -0.000316 0.005019 0.032401
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 6.431e-03 2.509e-03 2.563 0.010970 *
z.lag.1 -3.020e-01 1.089e-01 -2.772 0.005989 **
tt -1.214e-05 7.906e-06 -1.535 0.126034
z.diff.lag1 -6.211e-01 1.134e-01 -5.477 1.05e-07 ***
z.diff.lag2 -4.163e-01 1.131e-01 -3.682 0.000283 ***
z.diff.lag3 -3.239e-01 1.094e-01 -2.960 0.003366 **
z.diff.lag4 -3.323e-01 1.039e-01 -3.199 0.001555 **
z.diff.lag5 -3.007e-01 9.658e-02 -3.113 0.002065 **
z.diff.lag6 -2.511e-01 8.775e-02 -2.862 0.004566 **
z.diff.lag7 -2.214e-01 8.015e-02 -2.762 0.006171 **
z.diff.lag8 -2.117e-01 7.127e-02 -2.971 0.003256 **
z.diff.lag9 -1.637e-01 5.338e-02 -3.067 0.002402 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.008795 on 251 degrees of freedom
Multiple R-squared: 0.4919, Adjusted R-squared: 0.4697
F-statistic: 22.09 on 11 and 251 DF, p-value: < 2.2e-16
Value of test-statistic is: -2.772 2.6402 3.9242
Critical values for test statistics:
1pct 5pct 10pct
tau3 -3.98 -3.42 -3.13
phi2 6.15 4.71 4.05
phi3 8.34 6.30 5.36
summary( ur.ers(dy2t, type="P-test", lag.max=8, 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: 2.2919
Critical values of P-test are:
1pct 5pct 10pct
critical values 3.96 5.62 6.89
summary( ur.za(dy2t, model="trend") )
################################
# Zivot-Andrews Unit Root Test #
################################
Call:
lm(formula = testmat)
Residuals:
Min 1Q Median 3Q Max
-0.047757 -0.004905 -0.000625 0.004846 0.058874
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.269e-02 1.885e-03 6.730 1.01e-10 ***
y.l1 2.573e-02 6.044e-02 0.426 0.670573
trend 7.729e-05 2.062e-05 3.748 0.000218 ***
dt -1.842e-04 3.355e-05 -5.490 9.25e-08 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.01012 on 271 degrees of freedom
(1 observation deleted due to missingness)
Multiple R-squared: 0.1646, Adjusted R-squared: 0.1553
F-statistic: 17.79 on 3 and 271 DF, p-value: 1.427e-10
Teststatistic: -16.1208
Critical values: 0.01= -4.93 0.05= -4.42 0.1= -4.11
Potential break point at position: 123
summary( ur.kpss(dy2t, lags="short", type="tau") )
#######################
# KPSS Unit Root Test #
#######################
Test is of type: tau with 5 lags.
Value of test-statistic is: 0.5346
Critical value for a significance level of:
10pct 5pct 2.5pct 1pct
critical values 0.119 0.146 0.176 0.216
From the test we can say that \(y_{1,t}\) and \(y_{2,t}\) are \(I(1)\).
Trace test:
y <- cbind(dy1t,dy2t)
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] 4.202666e-01 1.205877e-01 1.665335e-16
Values of teststatistic and critical values of test:
test 10pct 5pct 1pct
r <= 1 | 35.21 7.52 9.24 12.97
r = 0 | 184.59 17.85 19.96 24.60
Eigenvectors, normalised to first column:
(These are the cointegration relations)
dy1t.l1 dy2t.l1 constant
dy1t.l1 1.0000000000 1.0000000 1.0000000
dy2t.l1 -1.0130644014 0.3990910 0.4654270
constant 0.0002461569 -0.0219225 -0.3301703
Weights W:
(This is the loading matrix)
dy1t.l1 dy2t.l1 constant
dy1t.d -0.4714651 -0.2720843 2.482761e-18
dy2t.d 0.8733907 -0.2671937 7.377070e-18
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] 4.202666e-01 1.205877e-01 1.665335e-16
Values of teststatistic and critical values of test:
test 10pct 5pct 1pct
r <= 1 | 35.21 7.52 9.24 12.97
r = 0 | 149.38 13.75 15.67 20.20
Eigenvectors, normalised to first column:
(These are the cointegration relations)
dy1t.l1 dy2t.l1 constant
dy1t.l1 1.0000000000 1.0000000 1.0000000
dy2t.l1 -1.0130644014 0.3990910 0.4654270
constant 0.0002461569 -0.0219225 -0.3301703
Weights W:
(This is the loading matrix)
dy1t.l1 dy2t.l1 constant
dy1t.d -0.4714651 -0.2720843 2.482761e-18
dy2t.d 0.8733907 -0.2671937 7.377070e-18
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.04 0.84
y.CA <- ca.jo(y, ecdet="none", type="trace", K=2, spec="transitory", season=4)
summary(y.CA)
######################
# Johansen-Procedure #
######################
Test type: trace statistic , with linear trend
Eigenvalues (lambda):
[1] 0.4202664 0.1204570
Values of teststatistic and critical values of test:
test 10pct 5pct 1pct
r <= 1 | 35.17 6.50 8.18 11.65
r = 0 | 184.55 15.66 17.95 23.52
Eigenvectors, normalised to first column:
(These are the cointegration relations)
dy1t.l1 dy2t.l1
dy1t.l1 1.000000 1.0000000
dy2t.l1 -1.013058 0.3991873
Weights W:
(This is the loading matrix)
dy1t.l1 dy2t.l1
dy1t.d -0.4714857 -0.2720636
dy2t.d 0.8733765 -0.2671794
y.CA <- ca.jo(y, ecdet="none", type="eigen", K=2, spec="transitory", season=4)
summary(y.CA)
######################
# Johansen-Procedure #
######################
Test type: maximal eigenvalue statistic (lambda max) , with linear trend
Eigenvalues (lambda):
[1] 0.4202664 0.1204570
Values of teststatistic and critical values of test:
test 10pct 5pct 1pct
r <= 1 | 35.17 6.50 8.18 11.65
r = 0 | 149.38 12.91 14.90 19.19
Eigenvectors, normalised to first column:
(These are the cointegration relations)
dy1t.l1 dy2t.l1
dy1t.l1 1.000000 1.0000000
dy2t.l1 -1.013058 0.3991873
Weights W:
(This is the loading matrix)
dy1t.l1 dy2t.l1
dy1t.d -0.4714857 -0.2720636
dy2t.d 0.8733765 -0.2671794
We can see that test for restricted constant indicate that ecdet="const" is not appropriate. Retesting for conintegration using alternative specification, we have a consistent test result using trace and max eigenvalue test.From the trace and max eigenvalue test we can say that \(y_t = (y_{1,t},y_{2,t})\) are cointegrated, we can first reject \(H_0: rank(\Pi) = 0\) and afterwards cannot reject \(H_0: rank(\Pi) = 1\).
y.VEC <- cajorls(y.CA, r=1)
y.VEC
$rlm
Call:
lm(formula = substitute(form1), data = data.mat)
Coefficients:
dy1t.d dy2t.d
ect1 -4.715e-01 8.734e-01
constant -2.144e-04 1.183e-04
sd1 -6.579e-05 -4.029e-05
sd2 1.177e-03 -3.430e-04
sd3 -1.233e-03 -1.628e-03
dy1t.dl1 -4.009e-01 -3.171e-01
dy2t.dl1 -2.318e-01 -1.242e-01
$beta
ect1
dy1t.l1 1.000000
dy2t.l1 -1.013058
rest.betta <- matrix(c(1,0,
0,-1), c(2,1))
summary( blrtest(y.CA, H=rest.betta, r=1) )
######################
# 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
Eigenvalues of restricted VAR (lambda):
[1] 0.4203 0.1205
The value of the likelihood ratio test statistic:
0 distributed as chi square with 0 df.
The p-value of the test statistic is: 1
Eigenvectors, normalised to first column
of the restricted VAR:
[,1] [,2]
[1,] 1.0000 1.0000
[2,] -1.0131 0.3992
Weights W of the restricted VAR:
[,1] [,2]
dy1t.d -0.4715 -0.2721
dy2t.d 0.8734 -0.2672
Test result indicate that we cannot reject the hypothesis that \(\beta_2 = -1\).
rest.alpha <- matrix(c(1,0), c(2,1))
summary(alrtest(y.CA, A=rest.alpha, r=1) )
######################
# 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]
[1,] 1
[2,] 0
Eigenvalues of restricted VAR (lambda):
[1] 0.2957 0.0000
The value of the likelihood ratio test statistic:
53.33 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]
RK.dy1t.l1 1.0000
RK.dy2t.l1 -0.7608
Weights W of the restricted VAR:
[,1]
[1,] -0.9684
[2,] 0.0000
Test result indicate that we cannot reject the hypothesis that \(\alpha_2 = 0\).
summary( ablrtest(y.CA, A=rest.alpha, H=rest.betta, r=1) )
######################
# Johansen-Procedure #
######################
Estimation and testing under linear restrictions on alpha and beta
The VECM has been estimated subject to:
beta=H*phi and/or alpha=A*psi
[,1] [,2]
[1,] 1 0
[2,] 0 -1
[,1]
[1,] 1
[2,] 0
Eigenvalues of restricted VAR (lambda):
[1] 0.2957 0.0000
The value of the likelihood ratio test statistic:
53.33 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]
[1,] 1.0000
[2,] -0.7608
Weights W of the restricted VAR:
[,1]
[1,] -0.9684
[2,] 0.0000
Test result indicate that we can reject the hypothesis that \(\beta_2 = -1\) and \(\alpha_2 = 0\).
y.VAR <- vec2var(y.CA, r=1)
y.VAR.fcst <- predict(y.VAR, n.ahead=8)
plot(y.VAR.fcst)