Data Science Center

Twelve labs, thirty-plus interactive experiments, a project studio that analyses your files locally, a dataset library, learning paths and a specialised assistant.

41interactive experiments

Data Science Center

Time Series Lab

Decomposition, moving averages, forecasting and model comparison.

  • 3lessons
  • 4experiments
  • 5terms
عربي

Scientific introduction

A time series is ordered in time, so it cannot be split randomly and its observations are not independent. It is decomposed into trend, seasonality and remainder, and forecasts are evaluated on a period after the training window.

Learning objectives

  • Decompose a series into trend, seasonality and remainder
  • Use moving averages and exponential smoothing
  • Understand stationarity, differencing and autocorrelation
  • Compare forecasts on a later hold-out period

Topics

  • Decomposition
  • Smoothing
  • ARIMA
  • Evaluation

Core concepts

Trend
A long-run change in the level of a series.
Seasonality
A pattern that repeats with a fixed period such as weekly or yearly.
Stationarity
Constancy of a series' statistical properties over time.
Autocorrelation
Correlation of a series with its own past values at a given lag.
Naive forecast
Forecasting the last value or the last season's value as a benchmark.

Theory

Decomposition and stationarity

The model

A series splits into trend, seasonality and remainder; additively (y = T + S + R) or multiplicatively (y = T × S × R) when seasonal swings grow with the level.

Stationarity means constant mean, variance and autocorrelation over time. Differencing (y_t - y_{t-1}) usually removes a trend, and seasonal differencing removes seasonality.

Smoothing and forecasting

Methods

  • Moving average: smooths with a fixed window; its forecast is flat.
  • Simple exponential smoothing: exponentially decaying weights on the past.
  • Holt-Winters: level, trend and seasonality.
  • ARIMA: autoregression with differencing and moving-average errors.

Always compare against a naive benchmark (last value or last season) or you cannot tell whether the complexity is justified.

Evaluating forecasts

Errors

MAE and RMSE are in the series' units; MAPE is a percentage but breaks near zero. Choose the measure that fits the decision.

Splitting

Hold out the last part of the series for testing, or use rolling-origin evaluation. Do not split randomly. Watch for leakage: never compute statistics from the test period.

Worked examples

Why not split randomly

A random split lets the model train on the future and test on the past, giving falsely optimistic performance. Always use a temporal split.

Interactive experiments

Beginner Synthetic data

Time series decomposition

Learning goal: Separate trend, seasonality and remainder in a series with known structure.

Explanation and scientific documentation

A series with trend, seasonality and noise you control is generated, then decomposed and compared with the true components.

Data: A computer simulation with random numbers whose seed you can change; no real data.

Additive: y = T + S + R; trend by a centred moving average, seasonality by the average of each position in the cycle.

Limits: Heavy noise confuses the separation.

Beginner Synthetic data

Moving average and smoothing

Learning goal: See how the window changes smoothing and lag.

Explanation and scientific documentation

You choose a simple (SMA) or exponential (EMA) average and a window on a noisy series.

Data: A computer simulation with random numbers whose seed you can change; no real data.

A larger window smooths more but lags changes.

Limits: A moving-average forecast is flat.

Advanced Synthetic data

ARIMA concept (simplified)

Learning goal: Understand autoregression and differencing with a simple AR(p) forecast.

Explanation and scientific documentation

An AR(1) series is generated, coefficients estimated with the Yule-Walker equations, and h steps are forecast.

Data: A computer simulation with random numbers whose seed you can change; no real data.

Differencing d is applied, then AR(p) is estimated. The MA part is not included.

Limits: A simplified teaching implementation without MA or automatic order selection; it does not replace full statistical libraries.

Advanced Synthetic data

Comparing forecasting models

Learning goal: Compare six forecasts (naive, seasonal naive, mean of last season, exponential smoothing, Holt-Winters, AR on seasonal differences) on a later hold-out period.

Explanation and scientific documentation

The series is split in time and MAE and RMSE of each model are measured on the final part.

Data: A computer simulation with random numbers whose seed you can change; no real data.

We do not choose by training error; the criterion is hold-out error.

Limits: One synthetic series; model ranking may change on other series.

Related algorithms and methods

Holt-Winters

Triple exponential smoothing: level, trend, seasonality.

ARIMA

Autoregression with differencing and moving-average errors.

Suitable datasets

Practical projects

Assessment questions

Sources and references

  1. Hyndman, R. J., & Athanasopoulos, G. (2021). Forecasting: Principles and Practice (3rd ed.). OTexts Link (bibliographic data entered by the editor, not machine-checked)
  2. Box, G. E. P., Jenkins, G. M., Reinsel, G. C., & Ljung, G. M. (2015). Time Series Analysis: Forecasting and Control (5th ed.). Wiley (bibliographic data entered by the editor, not machine-checked)
  3. Cleveland, R. B., Cleveland, W. S., McRae, J. E., & Terpenning, I. (1990). STL: A seasonal-trend decomposition procedure based on loess. Journal of Official Statistics, 6(1), 3-73 (bibliographic data entered by the editor, not machine-checked)