#Problem 1
#Use Zivot-Andrews test to analyze the presence of a unit root and structural breaks in the following series:
#Question 1
#(a) Log transformed Retail and Food Services Sales FRED/RSAFS
library(tseries)
## Warning: package 'tseries' was built under R version 3.2.4
library(urca)
## Warning: package 'urca' was built under R version 3.2.4
library(Quandl)
## Warning: package 'Quandl' was built under R version 3.2.4
## 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
Retail <- Quandl("FRED/RSAFS", api_key="T8gDpM8iFjXR9pfbXBmx", type = "zoo")
str(Retail)
## 'zooreg' series from Jan 1992 to Jan 2016
## Data: num [1:289] 164083 164260 163747 164759 165617 ...
## Index: Class 'yearmon' num [1:289] 1992 1992 1992 1992 1992 ...
## Frequency: 12
plot(Retail, xlab= "Time Period", ylab="Food and Services Sales")

lRetail <- diff(log(Retail))
ugiRetail <- ur.za(lRetail,model= "intercept", lag=12)
ugtRetail <- ur.za(lRetail,model= "trend", lag=12)
summary(ugiRetail)
##
## ################################
## # Zivot-Andrews Unit Root Test #
## ################################
##
##
## Call:
## lm(formula = testmat)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.039535 -0.004777 0.000459 0.004960 0.056613
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 8.299e-03 2.288e-03 3.627 0.000346 ***
## y.l1 -1.574e-01 2.385e-01 -0.660 0.509801
## trend -3.783e-05 1.387e-05 -2.727 0.006832 **
## y.dl1 3.097e-02 2.288e-01 0.135 0.892440
## y.dl2 3.043e-02 2.210e-01 0.138 0.890582
## y.dl3 4.548e-02 2.125e-01 0.214 0.830690
## y.dl4 8.477e-02 2.027e-01 0.418 0.676132
## y.dl5 4.724e-02 1.901e-01 0.248 0.803991
## y.dl6 1.319e-01 1.791e-01 0.737 0.461997
## y.dl7 1.230e-01 1.672e-01 0.736 0.462698
## y.dl8 5.276e-02 1.520e-01 0.347 0.728863
## y.dl9 1.604e-01 1.359e-01 1.181 0.238768
## y.dl10 1.963e-01 1.163e-01 1.687 0.092761 .
## y.dl11 1.952e-01 9.284e-02 2.102 0.036485 *
## y.dl12 3.760e-02 6.211e-02 0.605 0.545439
## du 5.494e-03 2.363e-03 2.325 0.020856 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.009694 on 259 degrees of freedom
## (13 observations deleted due to missingness)
## Multiple R-squared: 0.09842, Adjusted R-squared: 0.04621
## F-statistic: 1.885 on 15 and 259 DF, p-value: 0.02493
##
##
## Teststatistic: -4.8532
## Critical values: 0.01= -5.34 0.05= -4.8 0.1= -4.58
##
## Potential break point at position: 217
summary(ugtRetail)
##
## ################################
## # Zivot-Andrews Unit Root Test #
## ################################
##
##
## Call:
## lm(formula = testmat)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.040064 -0.004547 0.000458 0.005439 0.056878
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 6.367e-03 2.083e-03 3.057 0.00247 **
## y.l1 3.290e-02 2.174e-01 0.151 0.87982
## trend -2.495e-05 1.273e-05 -1.960 0.05108 .
## y.dl1 -1.481e-01 2.095e-01 -0.707 0.48019
## y.dl2 -1.371e-01 2.037e-01 -0.673 0.50161
## y.dl3 -1.092e-01 1.974e-01 -0.553 0.58055
## y.dl4 -5.526e-02 1.900e-01 -0.291 0.77135
## y.dl5 -7.693e-02 1.797e-01 -0.428 0.66893
## y.dl6 1.814e-02 1.700e-01 0.107 0.91509
## y.dl7 2.161e-02 1.598e-01 0.135 0.89250
## y.dl8 -3.395e-02 1.463e-01 -0.232 0.81661
## y.dl9 9.221e-02 1.321e-01 0.698 0.48595
## y.dl10 1.482e-01 1.144e-01 1.295 0.19651
## y.dl11 1.671e-01 9.228e-02 1.811 0.07132 .
## y.dl12 2.496e-02 6.216e-02 0.401 0.68839
## dt 5.263e-05 3.831e-05 1.374 0.17063
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.009759 on 259 degrees of freedom
## (13 observations deleted due to missingness)
## Multiple R-squared: 0.08627, Adjusted R-squared: 0.03335
## F-statistic: 1.63 on 15 and 259 DF, p-value: 0.06603
##
##
## Teststatistic: -4.449
## Critical values: 0.01= -4.93 0.05= -4.42 0.1= -4.11
##
## Potential break point at position: 201
adf.test(lRetail)
## Warning in adf.test(lRetail): p-value smaller than printed p-value
##
## Augmented Dickey-Fuller Test
##
## data: lRetail
## Dickey-Fuller = -5.4823, Lag order = 6, p-value = 0.01
## alternative hypothesis: stationary
#The p-value in ADF test is 0.01.Therefore, we reject the null hypothesis and the data is stationarity.
index(lRetail[ugiRetail@bpoint])
## [1] "Feb 2010"
#Hence the breaking point is February 2010.
#Question 2
#Log transformed Personal consumption expenditures: Nondurable goods (chain-type price index)FRED/DNDGRG3M086SBEA.
Personal <- Quandl("FRED/DNDGRG3M086SBEA",api_key="T8gDpM8iFjXR9pfbXBmx", type= "zoo")
str(Personal)
## '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(Personal, xlab= "Time Period", ylab="Price Index of Personal Consumption Expenditures")

lPersonal <- diff(log(Personal))
ugiPersonal <- ur.za(lPersonal,model= "intercept", lag=12)
ugtPersonal <- ur.za(lPersonal,model= "trend", lag=12)
summary(ugiPersonal)
##
## ################################
## # Zivot-Andrews Unit Root Test #
## ################################
##
##
## Call:
## lm(formula = testmat)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.036607 -0.002487 -0.000151 0.002385 0.023584
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.481e-03 4.832e-04 3.065 0.002264 **
## y.l1 4.825e-01 8.131e-02 5.933 4.81e-09 ***
## trend -5.565e-06 1.633e-06 -3.407 0.000697 ***
## y.dl1 -1.366e-02 8.129e-02 -0.168 0.866572
## y.dl2 -1.404e-01 8.027e-02 -1.749 0.080809 .
## y.dl3 -1.200e-01 7.810e-02 -1.537 0.124887
## y.dl4 -8.697e-02 7.588e-02 -1.146 0.252133
## y.dl5 -9.391e-02 7.253e-02 -1.295 0.195834
## y.dl6 -7.687e-02 6.932e-02 -1.109 0.267883
## y.dl7 -5.345e-02 6.551e-02 -0.816 0.414871
## y.dl8 -5.617e-02 6.106e-02 -0.920 0.358021
## y.dl9 4.565e-03 5.677e-02 0.080 0.935935
## y.dl10 8.653e-03 5.078e-02 0.170 0.864751
## y.dl11 1.882e-01 4.396e-02 4.282 2.13e-05 ***
## y.dl12 3.564e-02 4.014e-02 0.888 0.374971
## du 2.252e-03 7.486e-04 3.008 0.002730 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.005013 on 655 degrees of freedom
## (13 observations deleted due to missingness)
## Multiple R-squared: 0.2814, Adjusted R-squared: 0.2649
## F-statistic: 17.1 on 15 and 655 DF, p-value: < 2.2e-16
##
##
## Teststatistic: -6.3648
## Critical values: 0.01= -5.34 0.05= -4.8 0.1= -4.58
##
## Potential break point at position: 161
summary(ugtPersonal)
##
## ################################
## # Zivot-Andrews Unit Root Test #
## ################################
##
##
## Call:
## lm(formula = testmat)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.036494 -0.002487 -0.000143 0.002293 0.023504
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -3.516e-04 7.764e-04 -0.453 0.65076
## y.l1 4.548e-01 8.402e-02 5.413 8.68e-08 ***
## trend 1.791e-05 6.143e-06 2.915 0.00367 **
## y.dl1 1.158e-02 8.350e-02 0.139 0.88977
## y.dl2 -1.162e-01 8.230e-02 -1.412 0.15838
## y.dl3 -9.778e-02 7.985e-02 -1.225 0.22120
## y.dl4 -6.753e-02 7.727e-02 -0.874 0.38250
## y.dl5 -7.653e-02 7.368e-02 -1.039 0.29935
## y.dl6 -6.177e-02 7.022e-02 -0.880 0.37938
## y.dl7 -4.023e-02 6.623e-02 -0.607 0.54377
## y.dl8 -4.523e-02 6.157e-02 -0.735 0.46288
## y.dl9 1.359e-02 5.712e-02 0.238 0.81205
## y.dl10 1.517e-02 5.097e-02 0.298 0.76605
## y.dl11 1.930e-01 4.406e-02 4.380 1.38e-05 ***
## y.dl12 3.873e-02 4.017e-02 0.964 0.33530
## dt -2.363e-05 7.281e-06 -3.245 0.00123 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.005008 on 655 degrees of freedom
## (13 observations deleted due to missingness)
## Multiple R-squared: 0.283, Adjusted R-squared: 0.2666
## F-statistic: 17.23 on 15 and 655 DF, p-value: < 2.2e-16
##
##
## Teststatistic: -6.4889
## Critical values: 0.01= -4.93 0.05= -4.42 0.1= -4.11
##
## Potential break point at position: 177
adf.test(lPersonal)
## Warning in adf.test(lPersonal): p-value smaller than printed p-value
##
## Augmented Dickey-Fuller Test
##
## data: lPersonal
## Dickey-Fuller = -6.2301, Lag order = 8, p-value = 0.01
## alternative hypothesis: stationary
#The p-value in ADF test is 0.01 . Therefore, we reject the null hypothesis and the data is stationary.
index(lPersonal[ugiRetail@bpoint])
## [1] "Feb 1977"
#Hence the break point is February 1977.
#Problem 3
#Log transformed real wage per hour in manufacturing, constructed by dividing the Average Hourly Earnings of Production and Nonsupervisory Employees in Manufacturing, FRED/DNDGRG3M086SBEA,with the Personal Consumption Expenditures: Chain-type Price Index FRED/PCECTPI
Hearning <- Quandl("FRED/CES3000000008",api_key="T8gDpM8iFjXR9pfbXBmx",type= "zoo")
str(Hearning)
## 'zooreg' series from Jan 1939 to Feb 2016
## Data: num [1:926] 0.49 0.49 0.49 0.49 0.49 0.49 0.48 0.49 0.49 0.5 ...
## Index: Class 'yearmon' num [1:926] 1939 1939 1939 1939 1939 ...
## Frequency: 12
Pconsumption <- Quandl("FRED/PCECTPI",api_key="T8gDpM8iFjXR9pfbXBmx", type= "zoo")
str(Pconsumption)
## 'zooreg' series from 1947 Q1 to 2015 Q4
## Data: num [1:276] 13 13.1 13.4 13.7 13.9 ...
## Index: Class 'yearqtr' num [1:276] 1947 1947 1948 1948 1948 ...
## Frequency: 4
plot(Hearning, xlab = "Year", ylab = "Hourly Earnings")

plot(Pconsumption, xlab = "Year", ylab = "Consumption Index")

rwphr <- Hearning/Pconsumption
## Warning in merge.zoo(e1, e2, all = FALSE, retclass = NULL): Index vectors
## are of different classes: yearmon yearqtr
lrwphr <- log(rwphr)
plot(lrwphr)

uirwphr <- ur.za(lrwphr, model = "intercept", lag = 12)
summary(uirwphr)
##
## ################################
## # Zivot-Andrews Unit Root Test #
## ################################
##
##
## Call:
## lm(formula = testmat)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.0198209 -0.0034947 -0.0000492 0.0034537 0.0215349
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -5.107e-02 1.367e-02 -3.734 0.000234 ***
## y.l1 9.738e-01 6.361e-03 153.084 < 2e-16 ***
## trend 5.060e-05 1.867e-05 2.710 0.007205 **
## y.dl1 -8.124e-02 6.060e-02 -1.341 0.181297
## y.dl2 9.410e-02 5.995e-02 1.570 0.117743
## y.dl3 1.384e-01 6.020e-02 2.298 0.022393 *
## y.dl4 -1.486e-01 6.035e-02 -2.462 0.014484 *
## y.dl5 -8.653e-02 6.032e-02 -1.435 0.152686
## y.dl6 8.189e-02 5.890e-02 1.390 0.165634
## y.dl7 4.333e-02 5.822e-02 0.744 0.457461
## y.dl8 -1.101e-01 5.790e-02 -1.901 0.058484 .
## y.dl9 -6.505e-02 5.750e-02 -1.131 0.258999
## y.dl10 1.142e-02 5.752e-02 0.199 0.842808
## y.dl11 2.170e-02 5.719e-02 0.379 0.704673
## y.dl12 -1.561e-01 5.721e-02 -2.729 0.006818 **
## du -5.137e-03 1.771e-03 -2.900 0.004064 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.006494 on 247 degrees of freedom
## (13 observations deleted due to missingness)
## Multiple R-squared: 0.9987, Adjusted R-squared: 0.9986
## F-statistic: 1.287e+04 on 15 and 247 DF, p-value: < 2.2e-16
##
##
## Teststatistic: -4.1248
## Critical values: 0.01= -5.34 0.05= -4.8 0.1= -4.58
##
## Potential break point at position: 141
utrwphr <- ur.za(lrwphr, model = "trend", lag = 12)
summary(utrwphr)
##
## ################################
## # Zivot-Andrews Unit Root Test #
## ################################
##
##
## Call:
## lm(formula = testmat)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.0207897 -0.0034358 -0.0001453 0.0032919 0.0213759
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.0529281 0.0204321 -2.590 0.0102 *
## y.l1 0.9779809 0.0065248 149.886 <2e-16 ***
## trend 0.0005041 0.0004280 1.178 0.2400
## y.dl1 -0.0628335 0.0613183 -1.025 0.3065
## y.dl2 0.1086891 0.0605421 1.795 0.0738 .
## y.dl3 0.1517093 0.0608445 2.493 0.0133 *
## y.dl4 -0.1458259 0.0613088 -2.379 0.0181 *
## y.dl5 -0.0799328 0.0611246 -1.308 0.1922
## y.dl6 0.0950048 0.0598674 1.587 0.1138
## y.dl7 0.0615336 0.0595363 1.034 0.3024
## y.dl8 -0.0954320 0.0587802 -1.624 0.1057
## y.dl9 -0.0483870 0.0582285 -0.831 0.4068
## y.dl10 0.0344919 0.0579581 0.595 0.5523
## y.dl11 0.0494739 0.0576653 0.858 0.3918
## y.dl12 -0.1245866 0.0575961 -2.163 0.0315 *
## dt -0.0004877 0.0004230 -1.153 0.2500
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.006586 on 247 degrees of freedom
## (13 observations deleted due to missingness)
## Multiple R-squared: 0.9987, Adjusted R-squared: 0.9986
## F-statistic: 1.252e+04 on 15 and 247 DF, p-value: < 2.2e-16
##
##
## Teststatistic: -3.3747
## Critical values: 0.01= -4.93 0.05= -4.42 0.1= -4.11
##
## Potential break point at position: 24
adf.test(lrwphr)
##
## Augmented Dickey-Fuller Test
##
## data: lrwphr
## Dickey-Fuller = -3.4725, Lag order = 6, p-value = 0.04582
## alternative hypothesis: stationary
# The p-value is 0.04 less than 0.5 so we reject the null hypothesis. We accept alternate hypothesis. Therefore, log transformed data is stationary.
index(lrwphr[uirwphr@bpoint])
## [1] "Jan 1982"
#Hence the breaking point is January of 1982.