Learning Outcome
5
Apply techniques to convert non-stationary data → stationary
4
Use statistical tests (ADF & KPSS)
3
Understand types of stationarity
2
Identify visual signals of non-stationary data
1
Understand what stationarity means in time series.
Recall
Before this topic we learned:
Why do many models fail when the data keeps changing its behavior?
The Stock Market Problem
This is the core problem of non-stationary data.
The data behavior keeps changing.
Transition to Concept
Why Models Need Stable Data
Machine learning models assume: Future behaves similar to past
But if:
→ Model fails
Solution: Make the data stationary
A time series is stationary when its statistical properties do not change over time.
Mean
Mean
📊
Variance
Variance
📉
Autocorrelation
Autocorrelation
🔁
Models like ARIMA require stationarity
Stable properties include:
Key Difference:
Stationary Data
Non-Stationary Data
Two Types of Stationarity
Strict Stationarity:
Weak (Covariance) Stationarity:
Most models assume weak stationarity in time series data.
How to Visually Detect Non-Stationarity ?
Look for:
Example Plot:
Original Time Series Plot
Formal Tests for Stationarity:
Two popular tests:
These tests check whether data is stationary using hypothesis testing.
ADF Test
H₀ → Data is Non-Stationary
Decision Rule:
p-value < 0.05 → Stationary
p-value > 0.05 → Non-Stationary
KPSS Test (Opposite logic of ADF)
H₀ → Data is stationary
Decision Rule:
p-value < 0.05 → Non-Stationary
p-value > 0.05 → Stationary

ADF Test in Python
from statsmodels.tsa.stattools import adfuller
result = adfuller(series)
print(result[1]) # p-valuep-value < 0.05 → Stationary
Differencing Technique:
Formula: Yt − Y(t−1)
Purpose:
Log Transformation:
Formula: log(Y)
Used when:
Effect:


Time series → check stationarity → transform if needed → train ARIMA for forecasting.
5
Techniques like differencing and log transformation convert data to stationary
4
ADF and KPSS tests help statistically detect stationarity
3
Non-stationarity appears as trend, changing variance, or seasonality
2
Many forecasting models like ARIMA require stationary data
1
Stationarity means statistical properties remain constant over time

Quiz
Which statement about the ADF test is correct?
A. Null hypothesis: Data is stationary
B. Null hypothesis: Data is non-stationary
C. Used only for classification
D. Used to detect seasonality

Quiz
Which statement about the ADF test is correct?
A. Null hypothesis: Data is stationary
B. Null hypothesis: Data is non-stationary
C. Used only for classification
D. Used to detect seasonality