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
Quandl.api_key('4-KG5x_Vo7rXzmZNAHch')
library("tseries")
library("urca")
rsf <- Quandl("FRED/RSAFS", type="zoo")
lrsf <- log(rsf)
dlrsf <- diff(lrsf)
rsfin <- ur.za(dlrsf, model ="intercept", lag = 2)
summary(rsfin)
##
## ################################
## # Zivot-Andrews Unit Root Test #
## ################################
##
##
## Call:
## lm(formula = testmat)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.041913 -0.004756 0.000623 0.004939 0.058728
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 8.620e-03 1.566e-03 5.505 8.37e-08 ***
## y.l1 -1.715e-01 1.132e-01 -1.515 0.130894
## trend -4.366e-05 1.171e-05 -3.728 0.000234 ***
## y.dl1 2.285e-02 8.987e-02 0.254 0.799509
## y.dl2 -9.090e-04 5.933e-02 -0.015 0.987787
## du 6.634e-03 2.095e-03 3.166 0.001716 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.009598 on 279 degrees of freedom
## (3 observations deleted due to missingness)
## Multiple R-squared: 0.05951, Adjusted R-squared: 0.04265
## F-statistic: 3.531 on 5 and 279 DF, p-value: 0.004121
##
##
## Teststatistic: -10.348
## Critical values: 0.01= -5.34 0.05= -4.8 0.1= -4.58
##
## Potential break point at position: 207
rsftr <- ur.za(dlrsf, model = "trend", lag = 2)
summary(rsftr)
##
## ################################
## # Zivot-Andrews Unit Root Test #
## ################################
##
##
## Call:
## lm(formula = testmat)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.042286 -0.004704 0.000907 0.005557 0.058716
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 7.136e-03 1.537e-03 4.644 5.27e-06 ***
## y.l1 -1.048e-01 1.120e-01 -0.936 0.3499
## trend -2.758e-05 1.098e-05 -2.511 0.0126 *
## y.dl1 -1.864e-02 8.973e-02 -0.208 0.8356
## y.dl2 -1.953e-02 5.971e-02 -0.327 0.7438
## dt 5.858e-05 3.612e-05 1.622 0.1060
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.009723 on 279 degrees of freedom
## (3 observations deleted due to missingness)
## Multiple R-squared: 0.03482, Adjusted R-squared: 0.01752
## F-statistic: 2.013 on 5 and 279 DF, p-value: 0.07696
##
##
## Teststatistic: -9.8681
## Critical values: 0.01= -4.93 0.05= -4.42 0.1= -4.11
##
## Potential break point at position: 201
Part II
pc <- Quandl("FRED/DNDGRG3M086SBEA", type = "zoo")
str(pc)
## 'zooreg' series from Jan 1959 to Jan 2016
## Data: num [1:685] 19.9 19.9 19.9 19.9 19.9 ...
## Index: Class 'yearmon' num [1:685] 1959 1959 1959 1959 1959 ...
## Frequency: 12
plot(pc, xlab = "Periods", ylab = "consumption")
lpc <- log(pc)
dlpc <- diff(lpc)
pcin <- ur.za(dlpc, model = "intercept", lag = 2)
summary(pcin)
##
## ################################
## # Zivot-Andrews Unit Root Test #
## ################################
##
##
## Call:
## lm(formula = testmat)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.037686 -0.002492 -0.000169 0.002384 0.023808
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.692e-03 4.408e-04 3.838 0.000136 ***
## y.l1 3.717e-01 4.801e-02 7.741 3.61e-14 ***
## trend -6.566e-06 1.529e-06 -4.294 2.02e-05 ***
## y.dl1 1.041e-01 4.325e-02 2.406 0.016398 *
## y.dl2 -3.066e-02 3.847e-02 -0.797 0.425838
## du 2.766e-03 7.067e-04 3.913 0.000100 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.005087 on 675 degrees of freedom
## (3 observations deleted due to missingness)
## Multiple R-squared: 0.2396, Adjusted R-squared: 0.234
## F-statistic: 42.54 on 5 and 675 DF, p-value: < 2.2e-16
##
##
## Teststatistic: -13.088
## Critical values: 0.01= -5.34 0.05= -4.8 0.1= -4.58
##
## Potential break point at position: 161
pctr <- ur.za(dlpc, model = "trend", lag = 2)
summary(pctr)
##
## ################################
## # Zivot-Andrews Unit Root Test #
## ################################
##
##
## Call:
## lm(formula = testmat)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.037789 -0.002461 -0.000174 0.002199 0.023926
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -2.966e-04 7.100e-04 -0.418 0.676274
## y.l1 3.593e-01 4.846e-02 7.414 3.68e-13 ***
## trend 2.014e-05 5.298e-06 3.802 0.000157 ***
## y.dl1 1.117e-01 4.338e-02 2.575 0.010246 *
## y.dl2 -2.499e-02 3.853e-02 -0.649 0.516827
## dt -2.678e-05 6.280e-06 -4.265 2.28e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.005076 on 675 degrees of freedom
## (3 observations deleted due to missingness)
## Multiple R-squared: 0.2428, Adjusted R-squared: 0.2372
## F-statistic: 43.28 on 5 and 675 DF, p-value: < 2.2e-16
##
##
## Teststatistic: -13.2231
## Critical values: 0.01= -4.93 0.05= -4.42 0.1= -4.11
##
## Potential break point at position: 178
Part III
pm <- Quandl("FRED/CES3000000008", type= "zoo")
pi <- Quandl("FRED/PCECTPI", type= "zoo")
plot(pm, xlab = "Periods", ylab = "Earnings")
plot(pi, xlab = "Periods", ylab ="consumption")
pmi <- pm/pi
## Warning in merge.zoo(e1, e2, all = FALSE, retclass = NULL): Index vectors
## are of different classes: yearmon yearqtr
lpmi <- log(pmi)
plot(pmi)
plot(lpmi)
lpmiin <- ur.za(lpmi, model = "intercept", lag = 2)
summary(lpmiin)
##
## ################################
## # Zivot-Andrews Unit Root Test #
## ################################
##
##
## Call:
## lm(formula = testmat)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.0245103 -0.0036251 0.0002947 0.0033922 0.0259721
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -4.742e-02 1.230e-02 -3.855 0.000145 ***
## y.l1 9.760e-01 5.448e-03 179.136 < 2e-16 ***
## trend 4.856e-05 1.934e-05 2.510 0.012652 *
## y.dl1 -1.137e-01 5.962e-02 -1.907 0.057625 .
## y.dl2 1.890e-02 5.950e-02 0.318 0.750989
## du -4.550e-03 1.846e-03 -2.464 0.014353 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.007068 on 267 degrees of freedom
## (3 observations deleted due to missingness)
## Multiple R-squared: 0.9988, Adjusted R-squared: 0.9988
## F-statistic: 4.412e+04 on 5 and 267 DF, p-value: < 2.2e-16
##
##
## Teststatistic: -4.4124
## Critical values: 0.01= -5.34 0.05= -4.8 0.1= -4.58
##
## Potential break point at position: 141
lpmitr <- ur.za(lpmi, model = "trend", lag =2)
summary(lpmitr)
##
## ################################
## # Zivot-Andrews Unit Root Test #
## ################################
##
##
## Call:
## lm(formula = testmat)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.0250702 -0.0032966 -0.0001494 0.0035131 0.0257378
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.059126 0.020770 -2.847 0.00476 **
## y.l1 0.978992 0.005292 184.996 < 2e-16 ***
## trend 0.002837 0.002043 1.388 0.16618
## y.dl1 -0.097273 0.059881 -1.624 0.10546
## y.dl2 0.037990 0.059971 0.633 0.52697
## dt -0.002821 0.002041 -1.382 0.16806
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.007122 on 267 degrees of freedom
## (3 observations deleted due to missingness)
## Multiple R-squared: 0.9988, Adjusted R-squared: 0.9987
## F-statistic: 4.345e+04 on 5 and 267 DF, p-value: < 2.2e-16
##
##
## Teststatistic: -3.9697
## Critical values: 0.01= -4.93 0.05= -4.42 0.1= -4.11
##
## Potential break point at position: 7
adf.test(lpmi)
##
## Augmented Dickey-Fuller Test
##
## data: lpmi
## Dickey-Fuller = -3.4725, Lag order = 6, p-value = 0.04582
## alternative hypothesis: stationary