We use the Zivot-Andrew’s test to analyze the presence of a unit root and to test for structural breaks in the following time series:
Zivot-Andrew’s test is testing the null hypothesis: \(H_0: y_t=u+y_{t-1}+e_t\)
First we load the “Quandl” and “urca” packages.
library("Quandl")
library("tseries")
library("urca")
Then we run the log transformation of the Retail and Food Services Data.
retail<-Quandl("FRED/RSAFS", type="zoo")
logretail<-log(retail)
difflogretail<- diff(logretail,1)
par(mfrow=c(1,2))
plot(logretail,xlab="Time", ylab="Log of Retail")
plot(difflogretail,xlab="Time", ylab="Log Differences of Retail")
We can see that the Log Differences look stationary, however we are testing for structural breaks so we just look at the Log retail data on the left side. From first glance it looks like there is an intercept break in the data, and perhaps a small trend break in the data. However, we must verify this.
Lets run the Zivot Andrew’s test for the intercept.
logretailint.ur.za<- ur.za(logretail,model="intercept")
summary(logretailint.ur.za)
##
## ################################
## # Zivot-Andrews Unit Root Test #
## ################################
##
##
## Call:
## lm(formula = testmat)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.030909 -0.004945 0.000680 0.005223 0.059634
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.348e+00 2.424e-01 5.558 6.27e-08 ***
## y.l1 8.885e-01 2.013e-02 44.138 < 2e-16 ***
## trend 4.629e-04 8.526e-05 5.429 1.22e-07 ***
## du -2.258e-02 4.289e-03 -5.264 2.78e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.00927 on 284 degrees of freedom
## (1 observation deleted due to missingness)
## Multiple R-squared: 0.9989, Adjusted R-squared: 0.9989
## F-statistic: 8.97e+04 on 3 and 284 DF, p-value: < 2.2e-16
##
##
## Teststatistic: -5.5389
## Critical values: 0.01= -5.34 0.05= -4.8 0.1= -4.58
##
## Potential break point at position: 198
Since y.l1 is significant, we reject the unit root. We can also see that the du variable is significant and negative. We can say that there is a structural intercept break at position 198.
Now we see if there is a structural break in the trend.
logretailtrend.ur.za<- ur.za(logretail,model="trend")
summary(logretailtrend.ur.za)
##
## ################################
## # Zivot-Andrews Unit Root Test #
## ################################
##
##
## Call:
## lm(formula = testmat)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.039667 -0.004517 0.001009 0.004860 0.059932
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.880e-01 1.870e-01 2.610 0.00954 **
## y.l1 9.598e-01 1.560e-02 61.541 < 2e-16 ***
## trend 1.976e-04 8.780e-05 2.250 0.02519 *
## dt -9.970e-05 5.366e-05 -1.858 0.06419 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.009653 on 284 degrees of freedom
## (1 observation deleted due to missingness)
## Multiple R-squared: 0.9989, Adjusted R-squared: 0.9988
## F-statistic: 8.271e+04 on 3 and 284 DF, p-value: < 2.2e-16
##
##
## Teststatistic: -2.5797
## Critical values: 0.01= -4.93 0.05= -4.42 0.1= -4.11
##
## Potential break point at position: 95
Looking at the test summary, we can see that we reject the unit root and there is some significant evidence of a trend at break position 98. The trend p value is .025, which is not as strong as the evidence of an intercept break.
Now we look to see if there is a structural change in both.
logretailboth.ur.za<- ur.za(logretail,model="both")
summary(logretailboth.ur.za)
##
## ################################
## # Zivot-Andrews Unit Root Test #
## ################################
##
##
## Call:
## lm(formula = testmat)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.031246 -0.004726 0.000687 0.005266 0.059572
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.390e+00 2.707e-01 5.135 5.26e-07 ***
## y.l1 8.850e-01 2.249e-02 39.344 < 2e-16 ***
## trend 4.792e-04 9.688e-05 4.946 1.30e-06 ***
## du -2.274e-02 4.319e-03 -5.264 2.79e-07 ***
## dt -1.541e-05 4.332e-05 -0.356 0.722
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.009284 on 283 degrees of freedom
## (1 observation deleted due to missingness)
## Multiple R-squared: 0.9989, Adjusted R-squared: 0.9989
## F-statistic: 6.707e+04 on 4 and 283 DF, p-value: < 2.2e-16
##
##
## Teststatistic: -5.1148
## Critical values: 0.01= -5.57 0.05= -5.08 0.1= -4.82
##
## Potential break point at position: 198
When we run a test for both a trend break and an intercept break, we see that only the du is significant. This means is that there is an intercept break, but not a significant trend break. So what we have is we reject a unit root and find a structural break at position 198. The retail data is a trend stationary process with a structural interecept break on June 2008, which is position 198 in the retail data.
We the log transformation of the PCE data.
pce<-Quandl("FRED/DNDGRG3M086SBEA", type="zoo")
logpce<-log(pce)
difflogpce<- diff(logpce,1)
par(mfrow=c(1,2))
plot(logpce,xlab="Time", ylab="Log of PCE")
plot(difflogpce,xlab="Time", ylab="Log Differences of PCE")
We can see that the Log Differences look stationary, however we are testing for structural breaks so we just look at the Log PCE data on the left side. From first glance it looks like there are no intercept breaks and maybe two trend breaks. However, we should keep in mind that Zivot Andrew’s tests for just one structural break.
Lets run the Zivot Andrew’s test for the intercept.
logpceint.ur.za<- ur.za(logpce,model="intercept")
summary(logpceint.ur.za)
##
## ################################
## # Zivot-Andrews Unit Root Test #
## ################################
##
##
## Call:
## lm(formula = testmat)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.049466 -0.002308 -0.000204 0.002563 0.028046
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.194e-02 7.305e-03 5.742 1.41e-08 ***
## y.l1 9.865e-01 2.507e-03 393.469 < 2e-16 ***
## trend 2.013e-05 5.889e-06 3.418 0.000668 ***
## du 9.262e-03 1.187e-03 7.804 2.27e-14 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.005528 on 680 degrees of freedom
## (1 observation deleted due to missingness)
## Multiple R-squared: 0.9999, Adjusted R-squared: 0.9999
## F-statistic: 2.516e+06 on 3 and 680 DF, p-value: < 2.2e-16
##
##
## Teststatistic: -5.3701
## Critical values: 0.01= -5.34 0.05= -4.8 0.1= -4.58
##
## Potential break point at position: 169
Since y.l1 is significant, we reject the unit root. We can also see that the du variable is significant and negative. We can see that there is a structural intercept break at position 169 which is January 1973.
Now we see if there is a structural break in the trend.
logpcetrend.ur.za<- ur.za(logpce,model="trend")
summary(logpcetrend.ur.za)
##
## ################################
## # Zivot-Andrews Unit Root Test #
## ################################
##
##
## Call:
## lm(formula = testmat)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.049208 -0.002481 -0.000326 0.002567 0.028238
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.425e-02 7.083e-03 4.836 1.64e-06 ***
## y.l1 9.879e-01 2.575e-03 383.698 < 2e-16 ***
## trend 6.731e-05 1.204e-05 5.590 3.28e-08 ***
## dt -5.313e-05 7.766e-06 -6.841 1.76e-11 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.005581 on 680 degrees of freedom
## (1 observation deleted due to missingness)
## Multiple R-squared: 0.9999, Adjusted R-squared: 0.9999
## F-statistic: 2.468e+06 on 3 and 680 DF, p-value: < 2.2e-16
##
##
## Teststatistic: -4.6903
## Critical values: 0.01= -4.93 0.05= -4.42 0.1= -4.11
##
## Potential break point at position: 260
Looking at the test summary, we can see that we reject the unit root and there is significant evidence of a trend at break position 260. The date of this trend break is Aug 1980.
Now we look to see if there is a structural change in both.
logpceboth.ur.za<- ur.za(logpce,model="both")
summary(logpceboth.ur.za)
##
## ################################
## # Zivot-Andrews Unit Root Test #
## ################################
##
##
## Call:
## lm(formula = testmat)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.049318 -0.002268 -0.000249 0.002413 0.028181
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.756e-02 7.404e-03 5.073 5.06e-07 ***
## y.l1 9.873e-01 2.504e-03 394.272 < 2e-16 ***
## trend 4.469e-05 9.983e-06 4.477 8.88e-06 ***
## du 7.032e-03 1.389e-03 5.061 5.37e-07 ***
## dt -2.714e-05 8.933e-06 -3.038 0.00248 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.005495 on 679 degrees of freedom
## (1 observation deleted due to missingness)
## Multiple R-squared: 0.9999, Adjusted R-squared: 0.9999
## F-statistic: 1.91e+06 on 4 and 679 DF, p-value: < 2.2e-16
##
##
## Teststatistic: -5.0826
## Critical values: 0.01= -5.57 0.05= -5.08 0.1= -4.82
##
## Potential break point at position: 169
When we run a test for both a trend break and an intercept break, we see that both the du and dt is significant, but the du has stronger significance. The structural break that the test pics up is at position 169 which is January 1973.
We the log transformation of the Real Wage data.
avg<-Quandl("FRED/DNDGRG3M086SBEA", type="zoo")
pce2<-Quandl("FRED/PCECTPI", type="zoo")
realwage<-avg/pce2
## Warning in merge.zoo(e1, e2, all = FALSE, retclass = NULL): Index vectors
## are of different classes: yearmon yearqtr
logrealwage<-log(realwage)
diffrealwage<- diff(realwage,3)
par(mfrow=c(1,2))
plot(logrealwage,xlab="Time", ylab="Log of Real Wage Manufacturing")
plot(diffrealwage,xlab="Time", ylab="Log Differences Real Wage Manufacturing")
We can see that the Log Differences look stationary. Looking at the left side chart, we can see that there is one big intercept break in a stationary dataset. This data does not look trend stationary.
Lets run the Zivot Andrew’s test for the intercept.
logrw.ur.za<- ur.za(logrealwage,model="intercept")
summary(logrw.ur.za)
##
## ################################
## # Zivot-Andrews Unit Root Test #
## ################################
##
##
## Call:
## lm(formula = testmat)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.060506 -0.003679 -0.000590 0.004249 0.032882
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.039e-02 3.387e-03 3.067 0.002429 **
## y.l1 9.171e-01 2.213e-02 41.445 < 2e-16 ***
## trend 3.840e-06 1.838e-05 0.209 0.834729
## du -1.073e-02 3.103e-03 -3.459 0.000649 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.009129 on 223 degrees of freedom
## (1 observation deleted due to missingness)
## Multiple R-squared: 0.9799, Adjusted R-squared: 0.9796
## F-statistic: 3618 on 3 and 223 DF, p-value: < 2.2e-16
##
##
## Teststatistic: -3.7456
## Critical values: 0.01= -5.34 0.05= -4.8 0.1= -4.58
##
## Potential break point at position: 95
Since y.l1 is significant, we reject the unit root. We can also see that the du variable is significant and negative. We can see that there is a structural intercept break at position 95 which is July 1982.
Now we see if there is a structural break in the trend.
logrw.ur.za<- ur.za(logrealwage,model="trend")
summary(logrw.ur.za)
##
## ################################
## # Zivot-Andrews Unit Root Test #
## ################################
##
##
## Call:
## lm(formula = testmat)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.061670 -0.003593 -0.000742 0.003966 0.032433
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 8.643e-03 3.904e-03 2.214 0.0279 *
## y.l1 9.486e-01 2.023e-02 46.897 <2e-16 ***
## trend -6.251e-05 2.764e-05 -2.262 0.0247 *
## dt 9.257e-05 5.427e-05 1.706 0.0895 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.00931 on 223 degrees of freedom
## (1 observation deleted due to missingness)
## Multiple R-squared: 0.9791, Adjusted R-squared: 0.9788
## F-statistic: 3476 on 3 and 223 DF, p-value: < 2.2e-16
##
##
## Teststatistic: -2.5423
## Critical values: 0.01= -4.93 0.05= -4.42 0.1= -4.11
##
## Potential break point at position: 155
Looking at the test summary, we can see that we reject the unit root and there is no significant evidence of a structural break in trend.
Now we look to see if there is a structural change in both.
logrw.ur.za<- ur.za(logrealwage,model="both")
summary(logrw.ur.za)
##
## ################################
## # Zivot-Andrews Unit Root Test #
## ################################
##
##
## Call:
## lm(formula = testmat)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.060492 -0.003338 -0.000889 0.004163 0.033009
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 8.154e-03 3.208e-03 2.542 0.011716 *
## y.l1 9.232e-01 2.031e-02 45.450 < 2e-16 ***
## trend 4.336e-05 3.757e-05 1.154 0.249670
## du -1.155e-02 2.984e-03 -3.871 0.000143 ***
## dt -4.638e-05 4.410e-05 -1.052 0.294041
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.00908 on 222 degrees of freedom
## (1 observation deleted due to missingness)
## Multiple R-squared: 0.9802, Adjusted R-squared: 0.9798
## F-statistic: 2744 on 4 and 222 DF, p-value: < 2.2e-16
##
##
## Teststatistic: -3.7833
## Critical values: 0.01= -5.57 0.05= -5.08 0.1= -4.82
##
## Potential break point at position: 90
When we run a test for both a trend break and an intercept break, we see that du is significant, but dt is not. The break in intercept occurs at position 90 which is April 1981.
Overall, we reject the unit root and see that there is a structural break in the intercept on April 1981. When we test for just the intercept, we get a break for July 1982. They are roughly similar and can be explained by the differences in controlling for trend structural breaks.