library("zoo")
library("forecast")
library("tseries")
library("urca")
library ("Quandl")
Use Zivot-Andrews test to analyze the presence of a unit root and structural breaks in the following series:
This problem uses the Zivot-Adrews test to analyze the presence of unit root and structural break in the data set.
If the unit root tests find that a series contain one unit root, the appropriate route in this case is to transform the data by differencing the variables prior to their inclusion in the regression model, but this incurs a loss of important long-run information.
A well-known weakness of the ADF unit root tests is their potential confusion of structural breaks in the series as evidence of non-stationarity. In other words, they may fail to reject the unit root hypothesis if the series have a structural break.
This procedure can identify the date of the structural break, it facilitates the analysis of whether a structural break on a certain variable is associated with a particular event such as a change in government policy, a currency crisis, war and so forth. The Zivot-Andrews test only allow for one structural break. In Zivot-Andrews test a break date will be chosen where the evidence is least favorable for the unit root null. In the Zivot-Andrews tests, the null hypothesis is that the series has a unit root with structural break(s) against the alternative hypothesis that they are stationary with break(s). REject Null if t-value statistic is lower than tabulated critical value (left tailed test).
(a) Log transformed Retail and Food Services Sales FRED/RSAFS
The data used in this analyses is Retail and Food Services Sales from Quand.The Retail and Food Services Sales is Millions of Dollars Seasonally Adjusted monthly data from 1992 to 2016 January.
##R code for loading data
Ret_sale_d<- read.csv(file = "http://research.stlouisfed.org/fred2/data/RSAFS.csv", header=TRUE, sep=",")
Ret_sale<- ts(Ret_sale_d[,2], start=c(1992,1), frequency = 12)
str(Ret_sale)
## Time-Series [1:290] from 1992 to 2016: 164083 164260 163747 164759 165617 166098 167305 167797 169407 170681 ...
head(Ret_sale)
## [1] 164083 164260 163747 164759 165617 166098
tail(Ret_sale)
## [1] 446855 446929 448376 449744 447962 447308
tsdisplay(Ret_sale, lag.max = 100, xlab=" Years 1992-2016", ylab="Millions of Dollars", main="Retail and Food Services Sales, Millions of Dollars Seasonally Adjusted Monthly data from 1992 to 2016 January")
The plot above indicate increasing trend over the time frame. The ACF plot has continous decresaing, while PACF has no peaks.
##R code for Conducting Zivot and Adrews' test
l.Ret_sale<- log (Ret_sale)
adf.test(l.Ret_sale)
##
## Augmented Dickey-Fuller Test
##
## data: l.Ret_sale
## Dickey-Fuller = -2.0399, Lag order = 6, p-value = 0.5594
## alternative hypothesis: stationary
l.Ret_sale.za <- ur.za(l.Ret_sale, model="intercept", lag=1)
summary(l.Ret_sale.za)
##
## ################################
## # Zivot-Andrews Unit Root Test #
## ################################
##
##
## Call:
## lm(formula = testmat)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.034912 -0.004758 0.000519 0.005591 0.057392
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.302e+00 2.411e-01 5.399 1.42e-07 ***
## y.l1 8.924e-01 2.002e-02 44.575 < 2e-16 ***
## trend 4.440e-04 8.462e-05 5.247 3.03e-07 ***
## y.dl1 -9.793e-02 5.632e-02 -1.739 0.0832 .
## du -2.188e-02 4.255e-03 -5.142 5.07e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.009228 on 283 degrees of freedom
## (2 observations deleted due to missingness)
## Multiple R-squared: 0.999, Adjusted R-squared: 0.9989
## F-statistic: 6.736e+04 on 4 and 283 DF, p-value: < 2.2e-16
##
##
## Teststatistic: -5.3767
## Critical values: 0.01= -5.34 0.05= -4.8 0.1= -4.58
##
## Potential break point at position: 198
plot(l.Ret_sale.za)
The p-value in the ADF test is 0.5594, suggesting stationaty of data. The Zivot-Andrews test suggests that there is break in data trend at June 2008.The T-statistics of Z-A test is lower than critical value, REJECTING Null hypothesis of unit root. The data has structure break at June 2008.
(b) Log transformed Personal consumption expenditures: Nondurable goods (chain-type price index)FRED/DNDGRG3M086SBEA
The data used in this analyses is Personal consumption expenditures of Nondurable goods with chain-type price index from Quand.The RPersonal consumption expenditures of Nondurable goods is monthly data from 1959 to 2016 January.
##R code for loading data
per_consum_nd_d<- read.csv(file = "https://www.quandl.com/api/v3/datasets/FRED/DNDGRG3M086SBEA.csv", header=TRUE, sep=",")
per_consum_nd<- ts(per_consum_nd_d[,2], start=c(1959,1), frequency = 12)
str(per_consum_nd)
## Time-Series [1:685] from 1959 to 2016: 108 108 109 109 109 ...
head(per_consum_nd)
## [1] 107.700 108.172 108.961 108.950 108.862 109.848
tail(per_consum_nd)
## [1] 19.903 19.858 19.880 19.868 19.882 19.874
tsdisplay(per_consum_nd, lag.max = 100, xlab=" Years 1959-2016", ylab="chain-type price index", main="Personal consumption expenditures: Nondurable goods, chain-type price index Monthly data from 1959 to 2016 January")
The plot above indicate decreasing trend over the time frame. The ACF plot has continous decresaing, while PACF has no peaks.
##R code for Conducting Zivot and Adrews' test
l.per_consum_nd<- log (per_consum_nd)
adf.test(l.per_consum_nd)
##
## Augmented Dickey-Fuller Test
##
## data: l.per_consum_nd
## Dickey-Fuller = -1.7425, Lag order = 8, p-value = 0.6873
## alternative hypothesis: stationary
l.per_consum_nd.za <- ur.za(l.per_consum_nd, model="intercept", lag=1)
summary(l.per_consum_nd.za)
##
## ################################
## # Zivot-Andrews Unit Root Test #
## ################################
##
##
## Call:
## lm(formula = testmat)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.031482 -0.002027 0.000161 0.002254 0.039705
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 5.315e-02 1.040e-02 5.108 4.23e-07 ***
## y.l1 9.887e-01 2.158e-03 458.108 < 2e-16 ***
## trend -2.215e-05 4.824e-06 -4.590 5.27e-06 ***
## y.dl1 4.039e-01 3.449e-02 11.708 < 2e-16 ***
## du -5.907e-03 1.117e-03 -5.290 1.65e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.005048 on 678 degrees of freedom
## (2 observations deleted due to missingness)
## Multiple R-squared: 0.9999, Adjusted R-squared: 0.9999
## F-statistic: 2.263e+06 on 4 and 678 DF, p-value: < 2.2e-16
##
##
## Teststatistic: -5.2367
## Critical values: 0.01= -5.34 0.05= -4.8 0.1= -4.58
##
## Potential break point at position: 431
plot(l.per_consum_nd.za)
The p-value in the ADF test is -1.75, suggesting stationaty of data. The Zivot-Andrews test suggests that there is break in data trend at October 1994.The T-statistics of Z-A test is lower than critical value, REJECTING Null hypothesis of unit root. The data has structure break at October 1994.
(c) 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
The data used in this analyses is real wage per hour in manufacturing. This data is constructed from dividing the Average Hourly Earnings of Production and Nonsupervisory Employees in Manufacturing from Quand data source.The real wage per hour in manufacturing is monthly data from 1959 to 2016 January.
##R code for loading data
## avg_hr_Ear_d<- read.csv(file = "http://research.stlouisfed.org/fred2/data/CES3000000008.csv", header=TRUE, sep=",")
## per_consum_exp_d<- read.csv(file = "http://research.stlouisfed.org/fred2/data/PCECTPI.csv", header=TRUE, sep=",")
avg_hr_Ear_d <-Quandl("FRED/CES3000000008", type="zoo", collapse="quarterly")
per_consum_exp_d <- Quandl("FRED/PCECTPI", type="zoo" )
avg_hr_Ear <- window(avg_hr_Ear_d , start=c(1947))
per_consum_exp <- window(per_consum_exp_d)
RWP_hr<-avg_hr_Ear/per_consum_exp
str(RWP_hr)
## 'zooreg' series from 1947 Q1 to 2015 Q4
## Data: num [1:276] 0.0813 0.0837 0.0829 0.0845 0.0836 ...
## Index: Class 'yearqtr' num [1:276] 1947 1947 1948 1948 1948 ...
## Frequency: 4
head(RWP_hr)
## 1947 Q1 1947 Q2 1947 Q3 1947 Q4 1948 Q1 1948 Q2
## 0.08128834 0.08368201 0.08289768 0.08452962 0.08360360 0.08489085
tail(RWP_hr)
## 2014 Q3 2014 Q4 2015 Q1 2015 Q2 2015 Q3 2015 Q4
## 0.1790006 0.1794698 0.1818098 0.1818248 0.1828868 0.1831672
tsdisplay(RWP_hr, lag.max = 100, xlab=" Years 1947-2015", ylab="", main="real wage per hour in manufacturing, Quarterly data from 1947 to 2015")
The plot above indicate increasing trend over the time frame. The ACF plot has continous decresaing, while PACF has no peaks.
##R code for Conducting Zivot and Adrews' test
l.RWP_hr<- log (RWP_hr)
adf.test(l.RWP_hr)
##
## Augmented Dickey-Fuller Test
##
## data: l.RWP_hr
## Dickey-Fuller = -3.0992, Lag order = 6, p-value = 0.113
## alternative hypothesis: stationary
l.RWP_hr.za <- ur.za(l.RWP_hr, model="trend", lag=1)
summary(l.RWP_hr.za)
##
## ################################
## # Zivot-Andrews Unit Root Test #
## ################################
##
##
## Call:
## lm(formula = testmat)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.0191289 -0.0038172 -0.0001667 0.0037879 0.0232665
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.060206 0.015359 -3.920 0.000112 ***
## y.l1 0.980777 0.004593 213.556 < 2e-16 ***
## trend 0.003552 0.001265 2.807 0.005359 **
## y.dl1 -0.025736 0.058430 -0.440 0.659959
## dt -0.003539 0.001263 -2.803 0.005432 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.006389 on 269 degrees of freedom
## (2 observations deleted due to missingness)
## Multiple R-squared: 0.999, Adjusted R-squared: 0.999
## F-statistic: 6.859e+04 on 4 and 269 DF, p-value: < 2.2e-16
##
##
## Teststatistic: -4.1855
## Critical values: 0.01= -4.93 0.05= -4.42 0.1= -4.11
##
## Potential break point at position: 7
plot(l.RWP_hr.za)
The p-value in the ADF test is 0.113, suggesting stationaty of data. The Zivot-Andrews test suggests that there is break in data trend at October 1994.The T-statistics of Z-A test is lower than critical value, REJECTING Null hypothesis of unit root. The data has structure break at October 1948 Q4.