Augmented Dickey-Fuller Test in R, If a time series has no trend, constant variance over time, and a consistent autocorrelation structure across time, it is considered to be “stationary.”
An augmented Dickey-Fuller test, which uses the following null and alternative hypotheses to determine whether a time series is stationary, is one technique to do so.
H0: The time series is non-stationary.
To put it another way, it has some time-dependent structure and does not exhibit constant variance over time.
HA: The time series is stationary.
We can reject the null hypothesis and infer that the time series is stationary if the p-value from the test is less than some significance level (e.g. =0.05).
For a given time series, the following step-by-step example explains how to run an enhanced Dickey-Fuller test in R.
In R, an Augmented Dickey-Fuller test is an example.
Let’s pretend we have the following data in R:
data <- c(13, 54, 54, 65, 66, 71, 67, 67, 79, 88, 59, 52, 60)
We can make a fast plot to visualize the data before performing an augmented Dickey-Fuller test on it.
The adf.test() function from the tseries package can be used to run an augmented Dickey-Fuller test.
The code below demonstrates how to use this function.
perform augmented Dickey-Fuller test
adf.test(data) Augmented Dickey-Fuller Test data: data Dickey-Fuller = -1.6549, Lag order = 2, p-value = 0.7039 alternative hypothesis: stationary
Here’s how to interpret the most important p-value in the output.
We cannot reject the null hypothesis because the p-value is not smaller than 0.05.
This indicates that the time series is non-stationary. To put it another way, it has some time-dependent structure and does not exhibit constant variance over time.