
A stationary process is a fundamental concept in time series analysis. A time series is said to be stationary if its statistical properties—such as mean, variance, and autocorrelation—do not change over time. Understanding stationarity is crucial because many statistical and machine learning models assume that the data is stationary.
In this tutorial, we will cover:
A stationary process is a stochastic process whose statistical properties remain constant over time. This means that:
Mathematically, a time series Xt is strictly stationary if, for any time points t1, t2,...,tn and any time shift h:
This means the probability distribution remains unchanged over time.
Consider a white noise process:
Xt = et, where et ~ N(0,s2)
This is stationary because its mean is zero, variance is constant, and there is no correlation between values.
Download Python Code There are different degrees of stationarity.
A process is strictly stationary if the joint probability distribution does not change with time shifts. This is a strong requirement and is rarely used in practical applications.
A process is weakly stationary if:
Many time series models, such as ARMA and ARIMA, assume weak stationarity.
There are several ways to check if a time series is stationary.
Plot the time series and look for:
Download Python Code Calculate the rolling mean and rolling standard deviation. If they change over time, the series is non-stationary.
Download Python Code The ADF test is a statistical test where the null hypothesis is that the series has a unit root (i.e., it is non-stationary). If the p-value is below a significance level (e.g., 0.05), we reject the null hypothesis, indicating stationarity.
Download Python Code The KPSS test has the opposite hypothesis: the null hypothesis is that the series is stationary. If the p-value is below 0.05, we reject the null hypothesis, meaning the series is non-stationary.
Download Python Code If the series is non-stationary, we can apply transformations to make it stationary.
Subtract the previous value from the current value and check for stationarity again using ADF.
Download Python Code
Download Python Code
Download Python Code Let's use stock prices (which are usually non-stationary) and apply stationarity techniques. If the ADF p-value is below 0.05 after differencing, we have achieved stationarity.
Download Python Code 