The Diebold-Mariano Test
A statistical test for whether one forecasting model's accuracy is genuinely better than a rival's, or whether the observed difference in error could easily be luck.
Prerequisites: Forecast Evaluation and Accuracy Metrics
Two volatility models have been forecasting the same series for a year. Model A's average error (say, RMSE) came in at 1.20; Model B's came in at 1.35. Model A looks better — but is a gap of 0.15 real evidence that A is the superior forecaster, or could a coin-flip-different sample of the same underlying process have just as easily produced B looking better? Eyeballing two average error numbers and picking the smaller one ignores that both numbers are themselves estimates, computed from a finite, noisy sample of forecast errors, and therefore have their own sampling uncertainty. The Diebold-Mariano test turns "A's error is smaller than B's" into a proper hypothesis test with a p-value, so you know whether the gap is a real, statistically supported difference in forecasting skill.
An analogy: comparing two archers over many rounds
Two archers each shoot at a target, and after 50 arrows, archer A's average distance from the bullseye is slightly better than archer B's. Before declaring A the better archer, you'd want to know: was A consistently a little better on almost every arrow, or did A get lucky on just a couple of arrows while being roughly tied the rest of the time? If the arrow-by-arrow differences are noisy and only occasionally favor A, the average gap might not survive a rematch. The Diebold-Mariano test is this same check applied to forecast errors: look at the period-by-period difference in accuracy, see how consistent and how large that difference really is relative to its own noise, and only then conclude one forecaster is genuinely better.
The test, one symbol at a time
Define a loss differential at each time as the difference in some error measure (commonly squared error) between the two models' forecasts:
where is model A's loss (e.g., squared error) at time and is model B's. If A is systematically more accurate, should average out negative (A's losses are smaller); if the models are equally good, should average out near zero. The test statistic is
where is the sample average of across all forecast periods, and is an estimate of its sampling variance that accounts for the fact that forecast errors are typically autocorrelated over time (today's error and tomorrow's aren't independent), which an ordinary variance formula would understate. In plain English: DM measures how many standard errors the average loss gap is away from zero, properly accounting for the noisiness and time-dependence of that gap — under the null hypothesis of equal forecast accuracy, DM should behave like a standard normal variable, so values beyond roughly signal a statistically significant difference at the 5% level.
Worked example 1: computing DM by hand
Suppose over 4 days the squared errors are: Model A = , Model B = . The loss differentials are . The sample mean is . Suppose the estimated standard error of (accounting for autocorrelation) is 0.12. Then
Since , this falls short of standard 5% significance — despite Model A's average loss being noticeably lower in this small sample, there isn't yet enough statistical evidence, given the noise, to declare A significantly better; a larger sample or a more consistent gap would be needed.
Worked example 2: a clearer win
Now suppose a longer sample (250 days) yields with a smaller estimated standard error of 0.04 (more data shrinks the standard error). Then
With well beyond 1.96 (in fact beyond the 0.1% threshold of about 3.29), this is strong evidence that model A is genuinely more accurate, not merely luckier over this sample — a result a desk could act on, for instance by retiring model B or by weighting a forecast combination toward A.
What this means in practice
The Diebold-Mariano test is the standard way to justify replacing one production forecasting model with another, or to defend a forecast-combination weighting scheme (see Forecast Combination and Averaging), rather than relying on "the new model's backtest error looked smaller." It's routinely used to compare volatility forecasts, macro nowcasts, and any two competing time-series models built on the same target and evaluation window.
The Diebold-Mariano test checks whether the average difference in forecast loss between two models is large relative to its own sampling noise (accounting for autocorrelation in the errors) — turning "model A's error was smaller" into a proper statistical claim about which model is genuinely better, versus which one got lucky on this particular sample.
A frequent misuse is applying the standard DM test to two forecasts where one model was estimated using the other's data or a nested version of it (e.g., a small model versus a larger model that contains it as a special case) — the standard test's variance estimate is invalid in this "nested models" case and tends to over-reject, wrongly declaring the larger model significantly better even when it isn't. Nested model comparisons require a modified version of the test; always check whether the two competing models are genuinely non-nested before applying the textbook DM formula.
Related concepts
Practice in interviews
Further reading
- Diebold and Mariano, Comparing Predictive Accuracy, Journal of Business & Economic Statistics
- Diebold, Elements of Forecasting, ch. 12