# Understanding Dickey-Fuller-Result

I am currently looking into the dickey-fuller test but seem to not understand something fundamental. To understand the test better, I created 4 time series: cons, lin, r1 and r2. How these are generated can be seen in the code below. While r1 pulls samples from N(0,1), r2 follows the definition of a random walk. These are displayed as Figure 1. I would expect to obtain Z(t) > 0.05 for r2 and fail to reject H0 that it is a random walk. On the other hand, I would expect Z(t) < 0.05 for lin, con and r1 and reject H0 since these are certainly no random walks. UPDATE The results however are not as clear as I would hope, for these very basic examples. While I fail to reject H0 for r2 (as anticipated), the same applies for lin and con with much higher certainty. Only drawing random samples (r1) is correctly identified not to be a random walk with certainty.

. do "dickey-fuller-example.do"

. set obs 80
Number of observations (_N) was 0, now 80.

. gen points = _n

. gen cons = 0

. gen lin = 0.02 * _n

. gen r1 = 0

. replace r1 = rnormal() if _n>1

. gen r2  = 0

. replace r2 = r2[_n-1] + rnormal() if _n>1

.
. two con cons lin r1 r2 points, msize(small...)

.
. tsset points

Time variable: points, 1 to 80
Delta: 1 unit

.
. dfuller cons

DickeyFuller test for unit root           Number of obs  = 79
Variable: cons                             Number of lags =  0

H0: Random walk without drift, d = 0

DickeyFuller
Test      -------- critical value ---------
statistic           1%           5%          10%
--------------------------------------------------------------
Z(t)                 .       -3.539       -2.907       -2.588
--------------------------------------------------------------
MacKinnon approximate p-value for Z(t) = 1.0000.

. dfuller lin

DickeyFuller test for unit root           Number of obs  = 79
Variable: lin                              Number of lags =  0

H0: Random walk without drift, d = 0

DickeyFuller
Test      -------- critical value ---------
statistic           1%           5%          10%
--------------------------------------------------------------
Z(t)             0.151       -3.539       -2.907       -2.588
--------------------------------------------------------------
MacKinnon approximate p-value for Z(t) = 0.9694.

. dfuller r1

DickeyFuller test for unit root           Number of obs  = 79
Variable: r1                               Number of lags =  0

H0: Random walk without drift, d = 0

DickeyFuller
Test      -------- critical value ---------
statistic           1%           5%          10%
--------------------------------------------------------------
Z(t)            -7.259       -3.539       -2.907       -2.588
--------------------------------------------------------------
MacKinnon approximate p-value for Z(t) = 0.0000.

. dfuller r2

DickeyFuller test for unit root           Number of obs  = 79
Variable: r2                               Number of lags =  0

H0: Random walk without drift, d = 0

DickeyFuller
Test      -------- critical value ---------
statistic           1%           5%          10%
--------------------------------------------------------------
Z(t)            -2.186       -3.539       -2.907       -2.588
--------------------------------------------------------------
MacKinnon approximate p-value for Z(t) = 0.2112.

.
end of do-file


Can somebody explain me what happens here? These are my main questions?

• Why do I fail to reject H0 for r2 with comparatively low confidence?
• Why do I fail to reject H0 for lin and cons?
• Is there an easy example like this to confirm that the test works correctly?
• May I please ask you how exactly you generated this random time series rand?
– Alex
Commented Sep 30, 2022 at 23:30
• What @Alex said. In what sense is rand a random variable? It simply looks like a constant value repeated across time. Also you appear to contradict yourself following your graph: you expect to fail to reject $H_0$ for something that is not a random walk (rand), then you expect to reject $H_0$ for two things that are also not random walks. There's an inconsistency there. Commented Oct 1, 2022 at 3:22
• @Alex Hi Alex, I updated the body to include the code that generates the time series. Commented Oct 3, 2022 at 14:21
• @Alexis Hi Alexis, I updated the plot to show the time series more clearly. Now, I expect to fail to reject H0 for r2 only. Commented Oct 3, 2022 at 14:23

The Dickey-Fuller test has the null hypothesis $$\text{H}_{0}\text{: The time series has unit root},$$with the alternative hypothesis $$\text{H}_{\text{A}}\text{: The time series is stationary.}$$Caveat: evidence in favor of 'stationary' in the alternative hypothesis is agnostic regarding weak or strong stationarity.

You fail to reject $$\text{H}_{0}$$ of the Dickey-Fuller test for r2 because r2 is a random walk and has a unit root (i.e. was generated by a process conforming to $$\text{H}_{0}$$).

You fail to reject $$\text{H}_{0}$$ of the Dickey-Fuller test for lin because each observation of lin at time $$t$$ 'looks like' the value of the observation at $$t-1$$ plus a perturbation. The Dickey-Fuller test as you have specified it tests whether the estimated value of $$\beta=0$$ under the null in:

$$\Delta y_{t} = \alpha +\beta y_{t-1} + \varepsilon _{t}$$

As the value of $$\Delta y_{t}$$ in lin is uncorrelated with the value of $$y_{t-1}$$, there is no evidence to reject a hypothesized value of $$\beta=0$$.

You fail to reject $$\text{H}_{0}$$ of the Dickey-Fuller test for cons because there is no variation in the outcome. Here $$\Delta y_t = 0$$ at every point in time, and while it does not matter whether $$\alpha = 0$$ or not, $$\beta=0$$ for sure. The missing test statistic results from not having any variance estimate ($$\varepsilon=0$$ also).

These results, (along with the test rejecting the null for r1) are consistent with Stata's dfuller working correctly.