Stationarity Tests in Time SeriesTime series data is widely used in many disciplines, including signal processing, meteorology, finance, and economics. It is composed of observations that are gathered successively over an extended period of time. Stationarity is a key idea in the analysis of time series data. Stable statistical characteristics, such as a constant mean, constant variance, and time-independent autocovariance, are exhibited by a stationary time series. Making trustworthy forecasts and deriving significant conclusions from the data depend on stationarity. A stationary process is a process whose mean and variance do not change over time and the covariance between two periods depends on the distance between the periods, not the period under consideration. Now we will see various stationarity tests as we implement them. Code: Importing LibrariesOutput: Output: Output: Statistical Tests To DetectIn practice, it is extremely important to determine whether a time series is stationary (TSP or DSP). For this purpose, various unit root and stationarity tests have been developed. The most commonly used of these tests are the ADF test, PP test, DF-GLS test, ERS Point-Optimal test, NP test, and KPSS test. 01. Dickey-Fuller Unit-Root TestA hypothesis test that determines if a unit root exists in a time series dataset is called the Dickey-Fuller test. The absence of a steady mean across time and a stochastic trend are signs that a series is non-stationary, which is implied by a unit root. Formulated as follows, the DF test is based on a basic autoregressive model. Null Hypothesis (H0): The time series has a unit root, indicating non-stationarity. Alternative Hypothesis (H1): The time series is stationary. The test statistic is used to check if the null hypothesis can be rejected by comparing it with critical values taken from statistical tables. The null hypothesis is rejected and stationarity is suggested if the test statistic is smaller than the crucial value. In contrast, the existence of a unit root and non-stationarity indicates that the null hypothesis cannot be rejected if the test statistic is greater than the critical value. Output: 02. Augmented Dickey-Fuller testThe Augmented Dickey-Fuller test is an extension of the DF test that addresses potential shortcomings of the original test, such as low power and omitted variable bias. The ADF test incorporates additional lagged terms of the differenced series in the autoregressive model to account for autocorrelation and improve the test's efficiency. The ADF test allows for more flexible modeling of the data and provides more reliable results compared to the DF test, especially for small sample sizes. Output: 03. Phillip-Perron (PP) testIt bears the names of Pierre Perron and Peter C. B. Phillips, who developed it. The PP test is used, like the ADF test, to ascertain if a time series dataset has a unit root or is stationary. Some of the ADF test's shortcomings are addressed by the PP test, mainly its sensitivity to the definition of deterministic elements like trends and intercepts. Because the PP test is semi-parametric and non-parametric, it is less sensitive to the existence of deterministic components and does not depend on a particular model specification. The autoregressive model's ordinary least squares (OLS) estimate with a lagged difference term serves as the foundation for the PP test's test statistic. The test's null hypothesis is that the time series is non-stationary because it has a unit root. The series may be stationary, which is the alternate theory. Output: 04. Effective Unit Root TestsAn extension of the Dickey-Fuller (DF) test, which is frequently used in time series analysis and econometrics to determine if a unit root exists in a time series data set, is the Dickey-Fuller GLS (DF-GLS) test. By allowing for more flexible assumptions about the underlying data-generating process, the DF-GLS test solves some of the shortcomings of the classic DF test. In essence, the DF-GLS test is a GLS (Generalised Least Squares) regression, with the error term adjusted for autocorrelation and heteroscedasticity. Because of this, the DF-GLS test is more reliable and efficient than the conventional DF test, which uses ordinary least squares (OLS) estimation. The presence of a unit root in the time series, showing non-stationarity, is the null hypothesis of the DF-GLS test. The series may be stationary, which is the alternate theory. The distribution of the test statistic under the null hypothesis is known, and it is calculated using the estimated coefficients and their standard errors. One can decide whether to reject the unit root null hypothesis by comparing the test statistic to crucial values from the distribution. Output: 05. KPSS TestThe Kwiatkowski-Phillips-Schmidt-Shin test, or KPSS test, is a statistical technique that evaluates the stationarity null hypothesis in a time series dataset. In contrast to the Dickey-Fuller (DF) and Augmented Dickey-Fuller (ADF) tests, which look for the existence of a unit root, the KPSS test looks directly at trend-stationary behavior in a time series. The time series is stationary around a deterministic trend, which is the null hypothesis of the KPSS test. The alternative hypothesis is that the series has a unit root, indicating non-stationarity. The test compares crucial values from a pre-defined distribution to the sum of squared deviations of the observed series from the trend. Based on the sum of squared residuals from this regression, the test statistic is computed. The null hypothesis of stationarity is rejected in favor of non-stationarity if the test statistic rises over a critical number. In contrast, the null hypothesis cannot be disproved if the test statistic is smaller than the crucial value, indicating that the series is stationary. When the variance of a time series stays constant but the mean of the time series varies over time, this phenomenon is known as trend-stationarity, and the KPSS test is very helpful in identifying it. It is important to remember, nevertheless, that the KPSS test is not as effective at identifying other types of non-stationarity, such as difference-stationarity or structural fractures. Output: 06. Zivot Andrews TestA statistical technique called the Zivot-Andrews (ZA) test is used to determine if a unit root exists in a time series dataset that has structural breakdowns. The Zivot-Andrews test permits the existence of structural breakdowns or regime changes in the data, in contrast to conventional unit root tests like the Dickey-Fuller (DF) or Augmented Dickey-Fuller (ADF) tests, which presume that the series is stationary or follows a deterministic trend. The Zivot-Andrews test's null hypothesis is that the time series is non-stationary because it has a unit root. The series may be stationary around a trend with structural breakdowns, which is the alternate explanation. Consequently, if structural fractures occur, the Zivot-Andrews test may identify where they are as well as if a unit root is present. The sum of squared residuals from this regression is the basis for calculating the Zivot-Andrews test statistic. The null hypothesis of a unit root is rejected if the test statistic is greater than a critical value, meaning that the time series is stationary around a trend with structural breakdowns. Conversely, in the event that the test statistic falls below the crucial value, the null hypothesis remains valid and implies the presence of a unit root in the series. When there is previous information or suspicion of structural breakdowns in the time series data-such as adjustments in economic policy, interventions, or other external factors-the Zivot-Andrews test is very helpful. Output: Next TopicGraph Machine Learning |