Definition
For a target probability τ between 0 and 1, the pinball loss charges τ per unit when the actual value is above the forecast, and 1 − τ per unit when it is below. It comes from quantile regression, introduced by Koenker and Bassett in 1978.
Lτ(y, q) = τ (y − q) if y ≥ q, and (1 − τ) (q − y) if y < q
At τ = 0.9, running short costs nine times more per unit than holding one unit too many. The value of q that minimises the expected loss is the 0.9 quantile of the demand distribution. At τ = 0.5 the loss is half the absolute error and the optimum is the median.
Worked example
Weekly demand follows a Poisson distribution with mean 4. We score every integer stock level at τ = 0.9 and find the one with the lowest average loss.
import numpy as np
rng = np.random.default_rng(1)
demand = rng.poisson(4.0, size=50_000)
tau = 0.9
def pinball(y, q, tau):
d = y - q
return np.mean(np.where(d >= 0, tau * d, (tau - 1) * d))
for q in range(3, 10):
print(f"q = {q} pinball loss = {pinball(demand, q, tau):.4f} share of weeks covered = {np.mean(demand <= q):.3f}")
print("empirical 0.9 quantile:", int(np.quantile(demand, tau)))Output, produced by running the code above when this page was built:
q = 3 pinball loss = 1.2460 share of weeks covered = 0.435 q = 4 pinball loss = 0.7814 share of weeks covered = 0.630 q = 5 pinball loss = 0.5119 share of weeks covered = 0.784 q = 6 pinball loss = 0.3959 share of weeks covered = 0.891 q = 7 pinball loss = 0.3865 share of weeks covered = 0.948 q = 8 pinball loss = 0.4348 share of weeks covered = 0.978 q = 9 pinball loss = 0.5128 share of weeks covered = 0.992 empirical 0.9 quantile: 7
The loss is lowest at the smallest stock level that covers at least 90 % of the weeks, which is the 0.9 quantile. Levels below it are charged for shortages, levels above for excess.
Where it misleads
- The loss is in the units of the series. To average over items of different sizes it has to be scaled, as in the scaled pinball loss of the M5 uncertainty competition, which divides by the in-sample error of the naive forecast.
- On count data with small values, many neighbouring quantiles coincide. A loss at a single τ then separates methods poorly, and several levels should be scored together.
- A good pinball loss at 0.9 does not prove that 90 % of periods are covered. Coverage has to be checked separately.
Averaging the pinball loss over all probability levels gives the CRPS, which scores a whole predictive distribution.
In our work
A stock decision is a quantile, so we score quantiles. On 2,404 spare-part series the scaled quantile loss at 90 % was 0.364 for a Poisson quantile built on a moving average and 0.417 for the same quantile built on SBA: the point forecast underneath mattered more than the distribution placed on top of it.
Service: forecasting and statistical studies Research note: intermittent demand forecasting, measured
References
- Koenker, R., Bassett, G. (1978). Regression quantiles. Econometrica, 46(1), 33-50. doi:10.2307/1913643
- Gneiting, T., Raftery, A. E. (2007). Strictly proper scoring rules, prediction, and estimation. Journal of the American Statistical Association, 102(477), 359-378. doi:10.1198/016214506000001437
- Makridakis, S., Spiliotis, E., Assimakopoulos, V., Chen, Z., Gaba, A., Tsetlin, I., Winkler, R. L. (2022). The M5 uncertainty competition: results, findings and conclusions. International Journal of Forecasting, 38(4), 1365-1385. doi:10.1016/j.ijforecast.2021.10.009