Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Stationarity in Time Series | Section
Deconstructing Temporal Patterns

bookStationarity in Time Series

Swipe to show menu

Understanding whether a time series is stationary or non-stationary is a critical first step in time series analysis. A stationary time series has statistical properties – such as mean, variance, and autocorrelation – that do not change over time. This means the overall behavior of the series remains consistent, making it easier to model and predict. In contrast, a non-stationary time series shows trends, cycles, or changing variance, meaning its statistical properties evolve over time. Stationarity matters because many time series modeling techniques, such as ARIMA, assume the underlying data is stationary. Non-stationary data can lead to unreliable forecasts and misleading interpretations, so recognizing and transforming non-stationary series is often essential for accurate analysis.

12345678910111213141516171819202122232425262728293031323334
import numpy as np import pandas as pd import matplotlib.pyplot as plt np.random.seed(0) # Generate stationary time series: white noise stationary_series = np.random.normal(loc=0, scale=1, size=100) # Generate non-stationary time series: random walk random_steps = np.random.normal(loc=0, scale=1, size=100) non_stationary_series = np.cumsum(random_steps) # Create a DataFrame for plotting df = pd.DataFrame({ "Stationary": stationary_series, "Non-Stationary": non_stationary_series }) plt.figure(figsize=(12, 5)) plt.subplot(1, 2, 1) plt.plot(df["Stationary"]) plt.title("Stationary Series (White Noise)") plt.xlabel("Time") plt.ylabel("Value") plt.subplot(1, 2, 2) plt.plot(df["Non-Stationary"]) plt.title("Non-Stationary Series (Random Walk)") plt.xlabel("Time") plt.ylabel("Value") plt.tight_layout() plt.show()
copy

When you compare stationary and non-stationary time series visually, certain cues help you distinguish between them. A stationary series, such as white noise, fluctuates around a constant mean and maintains a consistent variance throughout the time span. In contrast, a non-stationary series – like a random walk – often displays trends, drifts, or changing variability, making the average level or spread change over time.

Key visual cues for stationarity:

  • Fluctuates around a constant mean;
  • Maintains consistent variance;
  • No obvious trend or seasonality is present.

Key visual cues for non-stationarity:

  • Shows trends or drifts over time;
  • Variance may increase or decrease;
  • Mean level may shift.

These visual cues are important because non-stationary data can mask underlying patterns or relationships, making statistical analysis and forecasting more challenging. Identifying and addressing non-stationarity is a foundational step before applying most time series models, as it ensures that the insights and predictions you derive are both valid and reliable.

Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 1. Chapter 2

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

Section 1. Chapter 2
some-alt