IKH

Stationarity Tests

In the previous segment of Auto Regressive models, you learnt about stationarity and its importance in forecasting a time series. 

Most of the time, visually, you can see that the series has a clear trend or seasonal component to comment about its stationarity. However, you cannot say that for sure as you also have to test whether its statistical properties, such as mean, variance etc. remain constant. There are some formal tests for checking this and you will learn more about them in this section.

Let’s study the two tests which are widely used to check the stationarity of a series.

You have studied two formal tests for stationarity based on hypothesis testing. The unit root test is a common procedure to determine whether a time series is stationary or not. 

Kwiatkowski-Phillips-Schmidt-Shin (KPSS) Test

  • Null Hypothesis (H0): The series is stationary
    • p−value>0.05
  • Alternate Hypothesis (H1): The series is not stationary
    • p−value≤0.05
  • Augmented Dickey-Fuller (ADF) Test 
  • Null Hypothesis (H0): The series is not stationary
    • p−value>0.05
  • Alternate Hypothesis (H1): The series is stationary
    • p−value≤0.05

Interpretation of p-value.

A p-value below a threshold (such as 5% or 1%) suggests we reject the null hypothesis, otherwise, a p-value above the threshold suggests we fail to reject the null hypothesis.

  • p−value>0.05: Fail to reject the null hypothesis (H0).
  • p−value≤0.05: Reject the null hypothesis (H0)

Now let’s see the coding demonstration to know if a series is stationary. In the next demonstration video, you will learn to make time plot to see visually if a time series is stationary along with the ADF test.

Now that you have understood how to perform the ADF test, let’s implement the KPSS test in Python as well.

In this segment, you learnt the theoretical concepts of two stationarity tests and saw how it can be implemented in Python on the airline passenger dataset. Now, it is time for you to check the stationarity of a real-world dataset using Python. Implement the KPSS test and ADF test on the data provided below and answer the following questions.

Comprehension

In the questions below, you will refer to the monthly exchange rate data. Exchange rate data consists of two columns – ‘Month’ and ‘Exchange rate’. The Exchange rate dataset can be downloaded from the link below:

Now, you might be thinking that most of the time series data have a trend and seasonal component and are hence non-stationary. So how can an Auto Regressive model be built on them? It turns out there are simple methods to convert non-stationary series into a stationary one. Let’s learn these methods in the next segment.

Report an error