2. Predictive Analytics

Regression and Forecasting

Estimate quantities and future demand with baselines, residuals and decision-relevant loss

Regression and Forecasting

Conditional mean, not automatic causality

A regression model may write daily orders as

Yt=β0+β1temperaturet+β2promotiont+εt.Y_t=\beta_0+\beta_1\text{temperature}_t+\beta_2\text{promotion}_t+\varepsilon_t.

β1\beta_1 describes a conditional relationship under the model. Calling it the effect of temperature or promotion requires assumptions about omitted causes, selection, timing and functional form.

Small fitted example

The following five-day dataset is a calculation exercise, not empirical evidence:

Temperature °COrders
10120
12126
14133
16141
18150

For simple least squares,

β^1=i(xixˉ)(yiyˉ)i(xixˉ)2,β^0=yˉβ^1xˉ.\hat\beta_1=\frac{\sum_i(x_i-\bar x)(y_i-\bar y)} {\sum_i(x_i-\bar x)^2},\qquad \hat\beta_0=\bar y-\hat\beta_1\bar x.
Py

Fit and audit a simple regression

Idle

The fitted slope is about 3.75 orders per degree within this narrow sample. Extrapolating to 35°C or claiming a causal response is unsupported.

Forecast origin and horizon

A forecast is indexed by both origin tt and horizon hh:

y^t+ht=E(Yt+hIt).\hat y_{t+h\mid t}=E(Y_{t+h}\mid\mathcal I_t).

The information set It\mathcal I_t must be frozen. A Monday replenishment forecast may use weather forecasts issued by Monday, not realised Thursday weather.

Choose loss from consequences

MetricFormula ideaBoundary
MAEmean $y-\hat y
RMSEsquare-root mean squared erroremphasises large misses
MAPEmean percentage errorunstable near zero
weighted absolute percentage$\sume
pinball lossasymmetric quantile erroruseful for service/stock trade-offs

If under-forecasting fresh milk costs more than over-forecasting canned goods, a single unweighted RMSE can select the wrong operational model.

Point and distribution

Inventory and staffing require uncertainty, not just a point. Report quantiles or prediction intervals and test their empirical coverage.

A nominal 90% interval should contain roughly 90% of comparable future outcomes. Coverage alone is not enough: an interval covering everything is uselessly wide. Compare calibration and sharpness.

Residual audit

Plot or tabulate residuals against:

  • fitted value and key inputs;
  • time and forecast horizon;
  • store, product and channel;
  • promotion and disruption periods;
  • missingness patterns.

Systematic residuals are information the model failed to encode or a sign that the data-generating process changed.

Quick check

Model A has lower daily RMSE; Model B has lower shortage cost in a replenishment simulation. Which wins?

Answer
For that replenishment decision, B is preferable if the simulation and costs are credible and constraints match deployment. Report the statistical trade-off and test sensitivity rather than claiming B is universally more accurate.

For deeper dynamic modelling, continue to the dedicated Time Series course.

Next: Classification and Calibration

Copyright © 2026