Quant techniques · forecasting

The Diebold–Mariano test: are two forecasts really different?

Model A has a lower RMSE than model B in your backtest. Is that evidence that A forecasts better, or did it win because of a few lucky days? The Diebold–Mariano test compares forecasts using a sequence of loss differences and asks whether one model has lower expected loss, allowing the differences to be serially correlated.

Loss differential and test statistic

Approximate DM statistic

100 independent differences with standard deviation 2. Serial dependence requires a long-run variance estimate.

Compare losses, not model coefficients

Let yty_t be the outcome and y^A,t,y^B,t\hat y_{A,t},\hat y_{B,t} be forecasts made using information available at the same origin and horizon. Choose a loss function L(e)L(e) and define

dt=L(yt−y^A,t)−L(yt−y^B,t).d_t=L(y_t-\hat y_{A,t})-L(y_t-\hat y_{B,t}).

The null is equal predictive accuracy, H0:E[dt]=0H_0:E[d_t]=0. With squared-error loss, a negative sample mean dˉ\bar d favours A. With absolute-error loss the comparison targets a different property, so the loss function should follow the decision problem rather than convenience.

The test statistic is

DM=dˉS^d(0)/T,DM=\frac{\bar d}{\sqrt{\hat S_d(0)/T}},

where S^d(0)\hat S_d(0) estimates the long-run variance of the loss differential. Under regularity conditions, this is asymptotically standard normal under the null. The test compares predictive accuracy; it does not test whether model parameters are equal or whether either model is correctly specified.

Why the long-run variance matters

For one-step forecasts with uncorrelated differentials, S^d(0)\hat S_d(0) may be estimated by the sample variance of dtd_t. But multi-step forecasts often overlap: a sequence of five-day returns forecast daily shares four days of realised outcomes. Even if the underlying innovations are independent, forecast errors and loss differences can then be serially correlated.

A heteroskedasticity-and-autocorrelation-consistent estimate uses

S^d(0)=γ^0+2∑k=1Lwkγ^k,\hat S_d(0)=\hat\gamma_0+2\sum_{k=1}^{L}w_k\hat\gamma_k,

where γ^k\hat\gamma_k is the lag-kk sample autocovariance, wkw_k are kernel weights (for example, Bartlett weights), and bandwidth LL is chosen to capture dependence. For overlapping hh-step forecasts, dependence through at least h−1h-1 lags is a natural starting point, though the exact dependence and bandwidth choice still deserve examination.

Keep the forecast experiment aligned

Forecasts must share the same target, horizon, information set, and evaluation dates. Comparing model A’s one-day forecasts with model B’s five-day forecasts does not isolate model accuracy. Any estimation or tuning must also respect the information available at each forecast origin.

Example interpretation

Suppose the average squared-error differential is dˉ=−0.12\bar d=-0.12, with HAC long-run standard deviation per observation S^d(0)=1.2\sqrt{\hat S_d(0)}=1.2, over T=144T=144 forecasts. Then

DM=−0.121.2/144=−1.2.DM=\frac{-0.12}{1.2/\sqrt{144}}=-1.2.

The negative sign favours A, but a two-sided 5% test would not reject equal accuracy because ∣DM∣<1.96|DM|<1.96. The result is not proof that the models are identical; it says the sample does not provide strong enough evidence of a nonzero mean loss differential under the test assumptions.

Practical choices and limitations

The classic test allows general loss functions and serial dependence under suitable conditions. In small samples, the normal approximation can be poor, especially with overlapping forecasts and persistent losses. Harvey, Leybourne, and Newbold proposed a finite-sample adjustment often used for this setting; alternative approaches include block bootstrap inference. State which method and bandwidth you use.

If one model nests the other, estimation uncertainty can affect the null distribution and the ordinary DM test may have low power or size distortions. Use a test designed for nested forecast comparisons, such as Clark–West in appropriate squared-error settings. If many models were screened and only the winner is reported, the p-value also ignores selection; adjust the research design for multiple comparisons or reserve a final untouched holdout.

Common mistakes

  • Using the variance of dtd_t as if observations were independent when multi-step losses overlap.
  • Reading a non-significant result as proof of equal performance.
  • Choosing the loss function after seeing which model wins.
  • Comparing forecasts that use different information sets or target definitions.
  • Reporting a DM p-value after extensive model search as if the winner had been specified in advance.

Practice

SignWith dₜ = loss(A) − loss(B), a significantly negative mean differential favours which model?
Show answer

Model A, because its average loss is lower than B’s under the chosen scoring rule.

OverlapWhy can five-day-ahead daily forecasts produce autocorrelated loss differentials?
Show answer

Their target periods overlap: adjacent forecasts share four of the five realised daily returns. This induces serial dependence even when daily shocks are independent.

InferenceA test gives p = 0.18. Can you conclude the models have equal expected loss?
Show answer

No. You fail to reject equal accuracy at conventional levels, but the data may be too noisy or the test may have low power. Report the estimate and uncertainty, not an equivalence claim.

Further reading: Diebold and Mariano (1995), “Comparing Predictive Accuracy,” Journal of Business & Economic Statistics 13(3), 253–263. Journal article.