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 timeindependent 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, DFGLS test, ERS PointOptimal test, NP test, and KPSS test. 01. DickeyFuller UnitRoot TestA hypothesis test that determines if a unit root exists in a time series dataset is called the DickeyFuller test. The absence of a steady mean across time and a stochastic trend are signs that a series is nonstationary, 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 nonstationarity. 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 nonstationarity indicates that the null hypothesis cannot be rejected if the test statistic is greater than the critical value. Output: 02. Augmented DickeyFuller testThe Augmented DickeyFuller 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. PhillipPerron (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 semiparametric and nonparametric, 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 nonstationary 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 DickeyFuller (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 DickeyFuller GLS (DFGLS) test. By allowing for more flexible assumptions about the underlying datagenerating process, the DFGLS test solves some of the shortcomings of the classic DF test. In essence, the DFGLS test is a GLS (Generalised Least Squares) regression, with the error term adjusted for autocorrelation and heteroscedasticity. Because of this, the DFGLS 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 nonstationarity, is the null hypothesis of the DFGLS 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 KwiatkowskiPhillipsSchmidtShin test, or KPSS test, is a statistical technique that evaluates the stationarity null hypothesis in a time series dataset. In contrast to the DickeyFuller (DF) and Augmented DickeyFuller (ADF) tests, which look for the existence of a unit root, the KPSS test looks directly at trendstationary 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 nonstationarity. The test compares crucial values from a predefined 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 nonstationarity 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 trendstationarity, 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 nonstationarity, such as differencestationarity or structural fractures. Output: 06. Zivot Andrews TestA statistical technique called the ZivotAndrews (ZA) test is used to determine if a unit root exists in a time series dataset that has structural breakdowns. The ZivotAndrews test permits the existence of structural breakdowns or regime changes in the data, in contrast to conventional unit root tests like the DickeyFuller (DF) or Augmented DickeyFuller (ADF) tests, which presume that the series is stationary or follows a deterministic trend. The ZivotAndrews test's null hypothesis is that the time series is nonstationary 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 ZivotAndrews 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 ZivotAndrews 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 datasuch as adjustments in economic policy, interventions, or other external factorsthe ZivotAndrews test is very helpful. Output:
Next TopicGraph Machine Learning
