8.2 Unit root testing

  • The first-order autoregression AR\((1)\) can be reparametrized by replacing \(y_t=\Delta y_t+y_{t-1}\) on the left hand side \[\begin{equation} \begin{aligned} \Delta y_t+y_{t-1}&=\alpha+\beta y_{t-1} + u_t \\ \Delta y_t&=\alpha + (\beta - 1)y_{t-1} + u_t \\ \Delta y_t&= \alpha + \lambda y_{t-1}+u_t,~~~~~~~~~~~~~~~~~\lambda=\beta-1 \end{aligned} \tag{8.12} \end{equation}\]

  • Testing for (non)stationarity comes down to testing the hypothesis about parameter \(\lambda\) \[\begin{equation} \begin{aligned} H_0:&~\lambda=0 \\ H_1:&~\lambda<0 \end{aligned} \tag{8.13} \end{equation}\]

  • The null hypothesis is true if the time-series contains a unit root (\(\lambda=0\)), which is an indicator of nonstationarity and the presence of a stochastic trend or a random walk (\(\beta=1\))

  • The last equation in (8.12) is referred as the Dickey-Fuller equation with a drift, and the unit root test is called Dickey-Fuller test (DF).

  • The Dickey-Fuller equation (8.12) may also include a linear trend: \[\begin{equation} \Delta y_t=\alpha+\lambda y_{t-1}+\gamma t+u_t \tag{8.14} \end{equation}\]

  • The Dickey-Fuller equation (8.12) may not include a drift term or a linear trend \[\begin{equation} \Delta y_t=\lambda y_{t-1} + u_t \tag{8.15} \end{equation}\]

  • The validity of any DF type test (without drift and without linear trend (8.15), or with drift and liner trend (8.14), or with drift term only (8.12)) requires that error terms \(u_t\) are independently and identically distributed (i.i.d.) random variables

  • If error terms \(u_t\) are identically distributed, it means they have the same mean (which is always zero) and the same (non-zero) variance, i.e. the error terms variance \(\sigma_u^2\) is finite and constant

  • If error terms \(u_t\) are independently distributed, it means that the covariance between any two lagged error terms is zero

  • A time-series of independently and identically distributed random variables is called white noise

  • If time-series of error terms \(u_t\) is white noise, the following holds:

\[\begin{equation} \begin{aligned} E(u_t)&=0~~~~~~~~~~~~~~~~\forall~t \\ Var(u_t)&=\sigma_u^2~~~~~~~~~~~~~~\forall~t \\ Cov(u_t,u_{t-k})&=0~~~~~~~~~~~~~~~~\forall~~t,~k \end{aligned} \tag{8.16} \end{equation}\]

  • If the error terms \(u_t\) do not follow white noise, any DF equation is extended on the RHS with lagged first differences \(\Delta y_{t-1}\), \(\Delta y_{t-2}\), \(\dots\), \(\Delta y_{t-p+1}\)

  • The number of additional terms is mostly determined by information criteria such as AIC or BIC, and thus, the augmented unit root test is called Augmented Dickey-Fuller test (ADF test)

If the null hypothesis of DF/ADF test in the levels is rejected, the time-series is stationary, i.e. the time-series is integrated of order zero \(y_t \sim I(0)\)

If the null hypothesis of DF/ADF test in the levels is not rejected, the time-series is nonstationary, and the DF/ADF test is conducted again using first differences

If the null hypothesis of DF/ADF test in the first differences is rejected, the differenced time-series is stationary, i.e. the time-series is integrated of order one \(y_t \sim I(1)\)

  • If stationarity is not achieved with first differences, second differences must be computed, and the DF/ADF test repeated.

  • Integrated time-series are difference-stationary

  • If the null hypothesis of the DF/ADF test is true, the distribution of the estimator \(\lambda\) does not follow a standard Student’s \(t-\)distribution, thus the test is performed by comparing DF/ADF test statistic

\[\begin{equation} t=\frac{\hat{\lambda}}{se(\hat{\lambda})} \tag{8.17} \end{equation}\]

\(~~~~~~~~\)with critical limits of DF distribution, which depend on equation type and the sample size.

  • If the test statistic (8.17) exceeds the critical limits (at \(10\%\), \(5\%\) or \(1\%\) significance level), the null hypothesis of the DF/ADF test is rejected

  • Furthermore, a time-series may only contain a deterministic (linear) trend. For such time-series, the null hypothesis of the DF/ADF test in the levels is usually not rejected.

  • If only a deterministic trend is present, the time-series should not be differenced but rather detrended, i.e. the variable \(y_t\) should be regressed on variable time \(t\) (the case of linear trend)

  • The stationarity of residuals from the linear trend is then tested using DF/ADF test without drift and without linear trend. If the residuals are stationary, the time-series is said to be trend-stationary

  • The assumption of white noise (independently and identically distributed error terms) can be verified by testing the significance of the autocorrelation coefficients

  • From the conditions (8.16), it follows that a time-series is a white noise if all autocorrelation coefficients are equal to \(0\) or at least insignificant:

\[\begin{equation} H_0:~~~~ \rho_1=\rho_2=\dots=\rho_m=0 \tag{8.18} \end{equation}\]

  • The critical limits for testing the null hypothesis (8.18) that the time-series is a white noise at \(95\%\) confidence level are approximately

\[\begin{equation} 0-\frac{2}{\sqrt{T}}~~~~,~~~0+\frac{2}{\sqrt{T}} \tag{8.19} \end{equation}\]

A formal statistical test used to determine whether a time-series is white noise (exhibits no significant autocorrelation at various lags) is the Ljung-Box test

\[\begin{equation} Q(m)=T(T+2)\sum_{k=1}^m \frac{\hat{\rho}_k^2}{T-k}~~~~~~k=1,2,...,m \tag{8.20} \end{equation}\]

Test statistic \(Q(m)\) follows a \(\chi^2\) distribution with \(m\) degrees of freedom. If the corresponding \(p-\)value of the \(\chi^2\) distribution is less than the significance level \(\alpha\), the null hypothesis is not rejected, concluding that there is no significant autocorrelation up to and including lag \(m\).

  • Note: there are several other unit root tests beyond the Augmented Dickey-Fuller (ADF) test, such as Phillips-Perron (PP) test, Kwiatkowski-Phillips-Schmidt-Shin (KPSS) test, or Zivot-Andrews (ZA) test (appropriate if structural breaks are suspected), but these tests will not be discussed here.

Exercise 37. Define \(6\) special cases for generating time-series \(y_t\) based on the parameter values \(\alpha\), \(\beta\) and \(\gamma\) in the table, and considering the following model; \[y_t=\alpha+\beta y_{t-1}+\gamma t+u_t~,~~~~~~~~~~u_t\sim WN(0,\sigma_u^2)\] \(~~~~~\)

Parameter \(~A~\) \(~B~\) \(~C~\) \(~D~\) \(~E~\) \(~F~\)
\(~~~~~\alpha\) \(0\) \(0\) \(0.2\) \(~~0\) \(~~1\) \(~~1\)
\(~~~~~\beta\) \(0\) \(1\) \(~~1\) \(~~1\) \(0.8\) \(~~0\)
\(~~~~~\gamma\) \(0\) \(0\) \(~~0\) \(0.2\) \(~~0\) \(0.2\)

\(~~~\)

  1. Time-series is trend-stationary. Case ______
  2. Time-series is pure random walk. Case ______
  3. Time-series is random walk with drift. Case ______
  4. Time-series is white noise. Case ______
  5. Time-series is stationary and without deterministic trend. Case ______
  6. Time-series exhibits both trends, deterministic and stochastic. Case ______
Solution When \(\alpha=\beta=\gamma=0\) a time-series equals to the withe noise \(y_t=u_t\), and thus case A corresponds to number \(4\). When parameter \(\beta=1\) a time-series has a unit root (random walk), and therefore, case B corresponds to number \(2\) (random walk without drift implies that \(\beta=1\) and \(\alpha=0\)), while case C corresponds to number \(3\) (random walk with drift implies that \(\beta=1\) and \(\alpha \ne 0\)). Similar to case B, case D is also a random walk without drift, but additionally includes a linear trend, which means that time-series exhibits both trends, i.e. case D corresponds to number \(6\). Case E represents an autoregression AR\((1)\) with parameter \(\beta\) less than \(1\) indicating a stationary time-series, i.e. case E corresponds to number \(5\). The last case F corresponds to number \(1\) as the given model \(~y_t=1+0.2t + u_t~\) is just a deterministic linear trend indicating trend-stationary time-series.
Exercise 38. Install and load the additional package urca in RStudio. Generate a random walk time-series y of length \(T=300\) as the cumulative sum of random normal variables with a zero mean and standard deviation of \(1\). Compute the first differences d.y using the diff() command. Calculate the means of the random walk and the first differences. Display \(4\) plots on a grid with \(2\) rows and \(2\) columns, including time-series y and d.y, as well as their autocorrelation functions (ACF) computed by the acf() command (up to and including \(20\) time lags). Display the autocorrelation coefficients of the time-series y in the console, and test their significance at lags \(1\), \(10\) and \(20\) by applying the Box.test() command. Do the same for the time-series d.y. Using the ur.df() command perform and ADF test with drift for the time-series y and an ADF test without drift for the time-series d.y. In both cases, use Akaike Information Criterion (AIC) for optimal lag selection. Which time-series is (non)stationary at the significance level \(5\%\)? Which time-series follows white noise and why? Is time-series y integrated of order one?
Solution Copy the code lines below to the clipboard and paste them into an R Script file opened in RStudio. In this example, the generated time-series y is a random walk with drift, which is nonstationary time-series because the ACF decays very slowly (illustrated by a correlogram). This is supported by the results of the Ljung-Box test, which indicates the statistical significance of the autocorrelation coefficients since the null hypothesis of the Ljung-Box test is rejected for time lags \(1\), \(10\) and \(20\). The nonstationarity of the time-series y is also confirmed by the ADF test, since the null hypothesis of the ADF test is not rejected at the \(5\%\) significance level because the test statistic \((-2.11)\) does not exceed the critical value tau1 \((-2.87)\). In this ADF type, drift term was included since the time-series y has a non-zero mean (argument type=“drift”). The first differences of the time-series d.y are stationary because all autocorrelation coefficients are insignificant, as confirmed by the Ljung-Box test. This further implies that the first-difference time-series follows white noise (any time-series that follows white noise is stationary, but the converse does not hold). The stationarity of the first-differences is also confirmed by the ADF test, as the null hypothesis of the ADF test is rejected at the \(5\%\) significance level because the test statistic \((-13.25)\) exceeds the critical value tau1 \((-1.95)\). In this ADF type, drift was omitted (argument type=“none” assume that time-series has a zero mean and does not account for any potential deterministic trend in the data). Finally, it can be concluded that the time-series y is nonstationary, while the first-differences d.y are stationary. This is supported by non rejection of the null hypothesis of the ADF test in the levels, and the rejection of the null hypothesis of the ADF test in the first differences. If a time-series becomes stationary after the first differencing, it is said to be integrated of the first order. Accordingly, this can be noted as \(~y_t \sim I(1)~\) and \(~\Delta y_t \sim I(0)~\). In given example, the first-difference series is also white noise WN.
# Installing and loading required package for unit root testing
install.packages("urca") # reguired only once
library(urca) 

set.seed(123) # setting the random seed to ensure reproducibility of RNG
y = ts(cumsum(rnorm(300, 0, 1))) # computing a time-series as a random walk of length 300 
d.y = diff(y) # computing the first differences of the random walk

# Calculating the means of random walk and first differences
mean(y) 
mean(d.y)

# Setting up a 2x2 grid for multiple plots layout (4 plots in total)
layout(matrix(c(1:4), nrow=2))
ts.plot(y, main="Random walk with non-zero mean", xlab="")  # plotting a random walk
ts.plot(d.y, main="First differences", xlab="")  # plotting the first differences
acf(y, lag.max=20, main="Corellogram of RW")  # plotting the ACF of random walk
acf(d.y, lag.max=20, main="Corellogram of first differences")  # plotting the ACF of the first differences

# Displaying autocorrelation coefficients (without plot)
acf(y, lag.max=20, plot=FALSE)
# Repeating Ljung-Box test for autocorrelation at lags 1, 10 and 20
Box.test(y,lag=1,type="Ljung-Box")
Box.test(y,lag=10,type="Ljung-Box")
Box.test(y,lag=20,type="Ljung-Box")

# Displaying autocorrelation coefficients (without plot)
acf(d.y, lag.max=20, plot=FALSE)
# Repeating Ljung-Box test for autocorrelation at lags 1, 10 and 20
Box.test(d.y,lag=1,type="Ljung-Box")
Box.test(d.y,lag=10,type="Ljung-Box")
Box.test(d.y,lag=20,type="Ljung-Box")

# Performing the Augmented Dickey-Fuller (ADF) test on the random walk
# Including a drift term whenever a time-series oscillate around a non-zero mean
summary(ur.df(y, type="drift", selectlags="AIC"))  # ADF test with drift

# Performing the Augmented Dickey-Fuller (ADF) test on the first differences
# Excluding a drift term whenever a time-series oscillate around zero
summary(ur.df(d.y, type="none", selectlags="AIC"))  # ADF test without drift

\(~~~\)