AI Glossary / Time series and signal processing / Intermediate
Error cost function
Definition
An error cost function assigns a loss or cost to a forecasting error. It describes how undesirable an error is as a function of its size, direction, or operational context. It can guide model fitting, forecast evaluation, and the choice of a point forecast or decision from a predictive distribution.
What it means
A forecast that is ten units too low may have a different consequence from one that is ten units too high. Underforecasting demand can cause shortages, while overforecasting can leave unused capacity.
An error cost function makes those consequences explicit. A familiar statistical score such as squared error is a particular choice, not a universal statement about business costs. The best forecast under one loss function can differ from the best forecast under another.
How it works
Define the forecast, the realized outcome, and the error sign convention. For example, let e = actual minus forecast, so positive error means underforecasting. State that convention before assigning asymmetric penalties.
A squared-error loss uses e squared. It penalizes large errors more strongly than small ones and treats equal positive and negative errors symmetrically. Under finite second moments, the conditional mean minimizes expected squared error.
An absolute-error loss uses the absolute value of e. It grows linearly with error magnitude, and a conditional median minimizes its expected value. This is a different statistical target from the mean for many asymmetric distributions.
An asymmetric linear cost can be written as cu times max(e,0) plus co times max(-e,0), where cu and co are positive underforecast and overforecast unit costs. An optimal point decision is a quantile at level cu/(cu+co), with possible nonuniqueness for discrete distributions.
Distinguish forecast accuracy from decision quality. If the forecast feeds a complicated scheduling or inventory policy, a simple function of forecast error may not capture fixed costs, constraints, lead times, or interactions across periods. A decision model may need the full predictive distribution.
Choose the evaluation loss before comparing model results. Selecting a score after seeing which model wins can create a misleading comparison. Assess models on the same forecast cases, horizons, and outcome definitions.
Check units and aggregation. Squared errors have squared outcome units; monetary costs require a justified mapping. Averaging errors over cases weights those cases equally unless a different weighting scheme is deliberately specified.
Estimate uncertain cost parameters and examine sensitivity. A forecast that is optimal for an assumed shortage cost may change when that cost changes. Report the operational assumptions separately from the statistical evidence, and avoid describing an asymmetric cost-minimizing decision as a neutral estimate of the mean.
Three practical examples
- A staffing planner penalizes insufficient capacity more heavily than modest idle capacity.
- A forecasting benchmark uses squared error because it explicitly targets conditional means.
- A replenishment simulator evaluates forecast-driven decisions using shortage and leftover costs rather than relying only on average absolute error.
Think of it this way
Think of choosing where to stand while catching a ball. Missing slightly to one side may be harmless, while missing to the other side may send it into a road. Distance alone does not describe the consequence; the penalty assigned to each kind of miss changes the best position.
Worked example
Consider an original one-period planning example. Demand is 80 units with probability 0.30, 100 with probability 0.50, and 140 with probability 0.20. Suppose the chosen forecast is used directly as available capacity. Each unit of shortage costs 9 cost units, and each unused unit costs 1, with no other costs or constraints.
At capacity 100, expected cost is 0.30 x 20 x 1 + 0.20 x 40 x 9 = 78. At capacity 140, expected cost is 0.30 x 60 x 1 + 0.50 x 40 x 1 = 38. At capacity 80, expected shortage cost is 0.50 x 20 x 9 + 0.20 x 60 x 9 = 198.
The target quantile is 9/(9+1) = 0.90. Since cumulative demand probability reaches only 0.80 at 100 and reaches 1 at 140, capacity 140 minimizes this piecewise-linear expected cost.
The mean demand is 102. It minimizes expected squared error, which is 436 there versus 1,880 at 140. Yet its operational expected cost is 76, higher than 38. Different loss functions therefore select different targets without either arithmetic calculation being wrong.
Illustrative case study
Fictional case: Seabrook Delivery evaluates two capacity forecasts using average squared error. Operations staff point out that missed deliveries are much more costly than a small amount of unused capacity.
The analysts retain a mean-forecast accuracy report but add a decision evaluation using documented shortage and surplus costs. They test how conclusions change across plausible cost assumptions rather than relabeling the higher-capacity decision as the most accurate mean forecast.
Common misconceptions and mistakes
A low statistical error score is not automatically a low business cost. Symmetric loss is a choice, not a necessity. Squared error is not measured in the original outcome units. A deliberately high quantile forecast is not necessarily biased relative to its intended target. Cost estimates should not be invented simply to justify the preferred model, and retrospective evaluation should not use information unavailable when decisions were made.
Business use
Error cost functions connect forecasting to the decisions it supports. They help teams explain why one model or point summary is preferred for a specific workflow. Record the loss function, units, horizon, weights, and cost assumptions. Where decisions interact across time, evaluate the complete policy rather than assuming isolated forecast errors tell the whole story.
People also ask
Must the function represent money?
No; it may be a statistical score or another explicit penalty.
Does the mean always give the best forecast?
Only for particular loss functions, including squared error under appropriate conditions.
Can one model win under one score and lose under another?
Yes.
Check your understanding
Why does the example choose capacity 140 under asymmetric costs?
Answer: Shortage is nine times as costly per unit as surplus.
Why does squared error prefer 102?
Answer: It targets the predictive mean.
Are those objectives interchangeable?
Answer: No.
Related terms
- Loss function
- Absolute error
- Pinball loss
- Decision theory
- squared error
- quantile forecast
- forecast evaluation
- predictive distribution
Learn next
Calculate expected loss for several candidate decisions under a small discrete forecast distribution. Then vary the underforecast and overforecast costs and observe how the preferred quantile changes.
More in Time series and signal processing
- Diagnostic checking - Diagnostic checking is the examination of a fitted model for signs that its assumptions or structure are inadequate for the intended use.
- Difference-equation filtering - Difference-equation filtering computes a discrete-time output from weighted current and past inputs and, in recursive filters, past outputs.
- Differencing - Differencing is a time-series transformation that replaces observations with changes between observations at a specified lag.
- Ex ante forecast - An ex ante forecast is a forecast produced using only information available at the time it is made.
- Exogenous variable - An exogenous variable is a variable whose value is treated as determined outside the model or system being analyzed.
- Exponential growth - Exponential growth is growth in which a quantity increases by a constant proportion over equal time intervals.
Work in finance? Get the free CFO AI Prompt Pack: 7 prompts for finance leaders.
Sources
Hyndman-hosted Glossary of Forecasting Terms, Error cost function: https://robjhyndman.com/mwh3/FG4.pdf Gneiting, Making and Evaluating Point Forecasts, primary author abstract: https://arxiv.org/abs/0912.0902 Gneiting, Quantiles as optimal point forecasts, primary journal abstract: https://www.sciencedirect.com/science/article/pii/S0169207010000063
Previous: Equivalence test Next: Error-driven learning