Path: blob/master/Time Forecasting using Python/1.1 Augmented Dickey-Fuller (ADF) test.ipynb
3074 views
The Augmented Dickey-Fuller (ADF) test is a statistical hypothesis test used to determine whether a unit root is present in a time series dataset. In simpler terms, it assesses whether a time series is stationary or non-stationary.
Stationarity is a key assumption in many time series analysis techniques, including ARIMA modeling. A stationary time series is one whose statistical properties (such as mean, variance, and autocorrelation) remain constant over time. Non-stationary time series, on the other hand, exhibit trends, seasonality, or other patterns that change over time.
What is Unit Root?
The ADF test belongs to a category of tests called Unit Root Test, which is the proper method for testing the stationarity of a time series.
Unit root is a characteristic of a time series that makes it non-stationary. Technically speaking, a unit root is said to exist in a time series of the value of alpha = 1 in the below equation:
-The presence of a unit root means the time series is non-stationary. Besides, the number of unit roots contained in the series corresponds to the number of differencing operations required to make the series stationary
The Augmented Dickey-Fuller (ADF) test holds significant importance in time series analysis for several reasons:
Assessing Stationarity: One of the fundamental assumptions in time series analysis is stationarity. The ADF test helps in determining whether a time series is stationary or non-stationary.
Model Selection: Stationarity is a prerequisite for many time series models, including autoregressive integrated moving average (ARIMA) models. The ADF test aids in model selection by guiding the choice of appropriate differencing orders.
Avoiding Spurious Regression: In regression analysis involving non-stationary time series, there is a risk of obtaining spurious regression results, where apparent relationships between variables are purely coincidental. By confirming stationarity through the ADF test, analysts can mitigate this risk and ensure the validity of their regression models.
Forecasting Accuracy: Stationary time series are typically easier to model and forecast accurately. By confirming stationarity using the ADF test, analysts can proceed with confidence in building forecasting models, leading to more reliable predictions.
Dickey-Fuller (DF)
A Dickey-Fuller test is a unit root test that tests the null hypothesis that α=1 in the following model equation. alpha is the coefficient of the first lag on Y.
Null Hypothesis (H0): alpha=1
ADF
ADF test is an ‘augmented’ version of the Dickey Fuller test.
The ADF test expands the Dickey-Fuller test equation to include high order regressive process in the model.
we have only added more differencing terms, while the rest of the equation remains the same. This adds more thoroughness to the test.
***The null hypothesis however is still the same as the Dickey Fuller test.
A key point to remember here is: Since the null hypothesis assumes the presence of unit root, that is α=1, the p-value obtained should be less than the significance level (say 0.05) in order to reject the null hypothesis. Thereby, inferring that the series is stationary.
ADF Test in Python:
The statsmodel package provides a reliable implementation of the ADF test via the adfuller() function in statsmodels.tsa.stattools. It returns the following outputs:
The p-value
The value of the test statistic
Number of lags considered for the test
The critical value cutoffs.
When the test statistic is lower than the critical value shown, you reject the null hypothesis and infer that the time series is stationary.
The p-value is very less than the significance level of 0.05 and hence we can reject the null hypothesis and take that the series is stationary.
Visual representation