Dickey-Fuller Test
Hypothesis Testing
Given that we have time series data eq1.
Explanation
The Dickey-Fuller test is a hypothesis test used to determine whether time series data has stationarity or not. If it does not have stationarity, differencing must be used to make the mean constant. It is important to note that this diagnosis only occurs for the mean. Since it does not concern variance, a separate test is required for that.
Code
Practice
In R, the adf.test()
function allows us to easily conduct the Dickey-Fuller test.
Let’s load the built-in data oil.price
.
Looking at the data, we can see a clear increasing trend as we move forward. In fact, conducting the Dickey-Fuller test shows that the p-value is very high at eq6. Since we cannot reject the null hypothesis, we cannot say that the data has stationarity.
On the other hand, after differencing, the data moves around eq7. Actually, when conducting the Dickey-Fuller test, the null hypothesis is rejected, indicating stationarity. However, as you can see, the variance increases over time. The Dickey-Fuller test indicating that the data has stationarity means that the mean is constant, not that it guarantees complete stationarity.
Full Code
library(tseries)
data("oil.price")
adf.test(oil.price)
adf.test(diff(oil.price))