Foundations to Frontier
Tests

Forecast metrics

A forecast is only as good as the way it is scored. Different error measures reward different forecasts: the mean absolute error rewards the median, the squared error the mean, and the percentage error a value below both. This page defines the common point metrics (MAE, RMSE, MAPE, sMAPE, MASE), the scores for quantiles, intervals and whole distributions (pinball loss, interval score, CRPS), and the Diebold–Mariano test for whether one forecast is really better than another.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

How wrong was the forecast?

A shop forecast 12, 18 and 30 sales and actually sold 10, 20 and 40. How wrong was it? You can average the absolute misses, square them so that big misses count more, or express them as percentages of what was sold. Each choice tells a different story, and if a forecaster is paid by one of them, they will learn to forecast the number that this measure likes best, which is not always the most likely one.

Time-series lab
The same forecast errors on a series at level 61: MAE 1.46, RMSE 1.85, MAPE 2.4%, MASE 0.55. Move the level towards 0: MAE, RMSE and MASE stay the same, but MAPE explodes because it divides by values near zero.
Why engineers care

Many retailers once ranked forecasts by percentage error and found that it quietly rewarded forecasts that were too low.

📝 Quick check (Level 0)
0/3 answered
  1. 1. Squaring the errors makes…
  2. 2. A percentage error divides the miss by…
  3. 3. Choosing an error measure…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

By hand

  • MAE = mean |y − f|; minimised by the median of the predictive distribution.
  • RMSE = √mean (y − f)²; minimised by the mean.
  • MAPE = 100 · mean |y − f| / |y|; undefined at y = 0, explodes near 0, and favours low forecasts.
  • sMAPE = 100 · mean 2|y − f| / (|y| + |f|); bounded but not symmetric in practice.
  • MASE = MAE / in-sample MAE of the (seasonal) naive forecast; scale-free and defined for intermittent data; below 1 beats the naive benchmark.
  • Pinball loss for a τ-quantile: τ(y − q) if y ≥ q, (1 − τ)(q − y) otherwise.
  • Interval score of a central (1 − α) interval: width + (2/α) × distance outside.
  • CRPS: the integral of the squared difference between the forecast CDF and the step at the outcome; it reduces to MAE for a point forecast.
  • Diebold–Mariano test: is the mean loss difference between two forecasts zero?
📝 Quick check (Level 1)
0/3 answered
  1. 1. MAE is minimised by the…
  2. 2. MASE below 1 means…
  3. 3. For a point forecast, the CRPS equals…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.

Computing the metrics

Exercise 1.

  • Outcomes 10, 20, 40 forecast as 12, 18, 30, with training data 8, 10, 9, 12, 11 for the MASE scale.
  • Pinball loss at τ = 0.9 for a quantile forecast 2 below and 2 above the outcome.
  • The Gaussian CRPS in closed form, checked against a Monte Carlo estimate.

Practice.

  • Pick the metric from the decision: if over- and under-forecasting cost the same, use MAE (median); if large misses are disproportionately costly, RMSE (mean); for asymmetric costs, the pinball loss at the matching quantile.
  • Avoid MAPE for data near zero or intermittent demand; prefer MASE or relative errors.
  • Compare across series with scale-free metrics (MASE, relative MAE with a geometric mean).
  • Score probabilistic forecasts with proper scores (CRPS, pinball, interval score), not coverage alone.
  • Test differences with Diebold–Mariano before declaring a winner.
  • Tools: sktime and darts metrics, properscoring, statsforecast.
import numpy as np

def mase(y, f, y_train, m=1):
    scale = np.mean(np.abs(y_train[m:] - y_train[:-m]))
    return np.mean(np.abs(y - f)) / scale
🐍 Exercise 1: point, quantile and distribution scores
Implement MAE, RMSE, MAPE, sMAPE and MASE, the pinball loss and the closed-form CRPS of a normal forecast, and check them on small hand-computed cases and by simulation.
📝 Quick check (Level 2)
0/3 answered
  1. 1. If large misses are disproportionately costly, use…
  2. 2. For intermittent demand, avoid…
  3. 3. Before declaring one forecast better, use…

Level 3: Advanced

★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.

Theory

Each metric has its own optimal forecast. For a predictive distribution of y, the forecast f minimising E|y − f| is the median, and the one minimising E(y − f)² is the mean. MAPE minimises E|y − f|/y, which is the median of a distribution reweighted by 1/y; small outcomes get more weight, so the optimum moves down. For lognormal y with log-mean μ and log-sd σ, this optimum is exp(μ − σ²), below the median exp(μ) and the mean exp(μ + σ²/2).

Proper scores. A score is proper if the forecaster gets the best expected score by reporting their true belief. The pinball loss is proper for a quantile, the interval score for a central interval, and the CRPS for a whole distribution. In Exercise 1 a 0.9-quantile forecast 2 below the outcome cost 1.8, but 2 above it only 0.2, which pushes the forecast up to the true 0.9-quantile.

Diebold–Mariano. With loss differential d_t = L(e_1t) − L(e_2t), the statistic mean(d) / √(V/n) is approximately standard normal when both forecasts are equally accurate. For h-step forecasts the errors overlap and d_t is autocorrelated up to lag h − 1, so V must be a long-run (HAC) variance.

📝 Quick check (Level 3)
0/3 answered
  1. 1. For lognormal outcomes, the MAPE-optimal forecast is…
  2. 2. A proper score rewards…
  3. 3. For h-step forecasts the DM test needs…

Level 4: Expert

★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.

Which forecast does each metric reward when demand is skewed, and how reliably does the Diebold–Mariano test tell a better forecast from an equally good one?

History.

  • MAPE and its problems were documented by J. S. Armstrong and F. Collopy (1992); sMAPE was used in the M3 competition (S. Makridakis and M. Hibon, 2000).
  • R. J. Hyndman and A. B. Koehler (2006) proposed MASE.
  • F. X. Diebold and R. S. Mariano (1995) gave the test; D. Harvey, S. Leybourne and P. Newbold (1997) corrected it for small samples.
  • T. Gneiting and A. E. Raftery (2007) set out proper scoring rules, including the CRPS and the interval score.

Exercise 2.

  • 20,000 lognormal demands with log-mean 3 and log-sd 0.5; the best constant forecast for each metric by grid search (step 0.05).
  • Diebold–Mariano at 5% on AR(1) data with φ = 0.7: the correct forecast 0.7·y versus 0.4·y (truly worse), and 0.6·y versus 0.8·y (equally good), 300 repetitions each.

Seed 0, best constant forecast:

metric best constant theory
MAE 20.05 median 20.09
RMSE 22.80 mean 22.76
MAPE 15.65 exp(μ − σ²) = 15.64
sMAPE 20.00 —

Seed 0, share of repetitions where DM said the forecasts differ:

test length 0.7 vs 0.4 (power) 0.6 vs 0.8 (size)
50 24% 3.7%
200 77% 7.0%
1000 100% 4.3%
  • MAPE rewarded a forecast 22% below the median: a forecaster judged by MAPE should under-forecast.
  • MAE and RMSE landed on the median and the mean, as the theory says; sMAPE landed near the median here.
  • The DM test kept its 5% level when the forecasts were equally good, but with 50 test points it caught the truly worse forecast only a quarter of the time: short backtests rarely separate similar models.
  • Seeds 1 and 2: MAPE optimum 15.55 and 15.80, MAE 20.0 and 20.2, RMSE 22.6 and 22.8; DM power at n = 200 74% and 80%, size at most 7%.
🐍 Exercise 2 (research): which forecast does each metric reward when demand is skewed, and how reliably does the Diebold–Mariano test tell a better forecast from an equally good one?
Find the constant forecast that each metric rewards on skewed demand, and measure the power and size of the Diebold–Mariano test at several test lengths.

Forecast evaluation in practice

  • Forecast competitions (M3, M4, M5) use scale-free metrics such as MASE, sMAPE and the weighted scaled pinball loss.
  • Hierarchies: errors at product, store and total level can rank models differently; score the level where decisions are made.
  • Value-based metrics: inventory cost, service level or revenue can replace statistical errors when the decision is known.
  • Multiple comparisons: testing many models against one benchmark needs corrections such as the model confidence set.

References

  1. J. S. Armstrong and F. Collopy (1992). “Error measures for generalizing about forecasting methods.” International Journal of Forecasting.
  2. R. J. Hyndman and A. B. Koehler (2006). “Another look at measures of forecast accuracy.” International Journal of Forecasting.
  3. F. X. Diebold and R. S. Mariano (1995). “Comparing predictive accuracy.” Journal of Business and Economic Statistics.
  4. T. Gneiting and A. E. Raftery (2007). “Strictly proper scoring rules, prediction, and estimation.” Journal of the American Statistical Association.
  5. S. Makridakis and M. Hibon (2000). “The M3-Competition: results, conclusions and implications.” International Journal of Forecasting.