Code of the Day
AdvancedTime Series

Time series structure

Trend, seasonality, and noise are the three components of any time series — and stationarity is the property most forecasting models require.

Data ScienceAdvanced7 min read
By the end of this lesson you will be able to:
  • Identify trend, seasonality, and noise as the three additive components of a time series
  • Define stationarity and explain why it matters for forecasting
  • Recognise non-stationary series from visual or statistical properties

A time series is a sequence of observations ordered by time: daily temperatures, monthly sales, hourly server request counts, annual population figures. The ordering by time is not incidental — it is the defining property, and it makes time series data behave differently from a table of independent observations. Rows in a time series are not exchangeable. The observation at time t depends on observations at earlier times.

The three components

Most time series can be understood as a mixture of three components:

Trend is the long-run direction of the series. A company's revenue might rise over years despite weekly noise. A population might decline over decades. Trend is what you see when you smooth away the short-term fluctuation and look at the overall direction.

Seasonality is a repeating pattern at a fixed period — daily, weekly, monthly, yearly. Retail sales spike every December. Web traffic dips every weekend. Energy consumption peaks on summer afternoons. Seasonality is deterministic in its timing even if its amplitude varies slightly.

Noise (also called the residual or irregular component) is everything left after removing trend and seasonality — random shocks, measurement error, events that cannot be modelled. The noise component is, by definition, unpredictable.

The three components combine in one of two ways:

Additive: y(t) = trend(t) + seasonal(t) + noise(t). Use this when the seasonal amplitude is roughly constant regardless of the trend level.

Multiplicative: y(t) = trend(t) × seasonal(t) × noise(t). Use this when the seasonal amplitude grows proportionally with the level of the series — if a growing business's December spike is 20% above the monthly average, the absolute spike gets larger as the business grows.

Stationarity

A time series is stationary if its statistical properties — mean, variance, autocorrelation structure — do not change over time. A series with an upward trend is not stationary (the mean is changing). A series with growing amplitude is not stationary (the variance is changing).

Most classical forecasting models (ARIMA and its variants) assume stationarity. Non-stationary series must be transformed before fitting: differencing (replace each observation with the change from the previous one) often removes a linear trend in one pass. Seasonal differencing removes seasonality.

The Augmented Dickey-Fuller (ADF) test is the standard statistical test for stationarity: a low p-value (below 0.05) rejects the null hypothesis of a unit root, supporting stationarity. statsmodels.tsa.stattools.adfuller provides this. For most practical work, visual inspection of the mean and variance over time is sufficient to diagnose obvious non-stationarity.

Why this matters for forecasting

A model that assumes the future resembles the past is valid only if the past is stationary. If your series has trend, the model needs to account for it — either by modelling the trend explicitly or by differencing it out. Ignoring trend produces systematic forecast errors that only grow as the forecast horizon extends.

Where to go next

Next: decomposing a series — using statsmodels to extract the three components numerically and decide whether additive or multiplicative decomposition fits better.

Finished reading? Mark it complete to track your progress.

On this page