File Exchange

image thumbnail

Diebold-Mariano Test Statistic

version 1.2.0.0 (1.48 KB) by Semin Ibisevic
Retrieves the Diebold-Mariano (1995) test statistic, taking into account autocorrelation.

18 Downloads

Updated 19 Feb 2017

View Version History

View License

Retrieves the Diebold-Mariano test statistic (1995) for the equality of forecast accuracy of two forecasts under general assumptions.
The function also corrects for the autocorrelation that multi-period forecast errors usually exhibit. Note that an efficient h-period forecast will have forecast errors following MA(h-1) processes. Diebold-Mariano use a Newey-West type estimator for sample variance of the loss differential to account for this concern.
References:
K. Bouman. Quantitative methods in international finance and macroeconomics. Econometric Institute, 2011. Lecture FEM21004-11.

Diebold, F.X. and R.S. Mariano (1995), "Comparing predictive accuracy", Journal of Business & Economic Statistics, 13, 253-263.

Cite As

Semin Ibisevic (2020). Diebold-Mariano Test Statistic (https://www.mathworks.com/matlabcentral/fileexchange/33979-diebold-mariano-test-statistic), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (12)

Hanqing Liu

Laurens Swinekls

I have two questions about this file:

(1) The bug-fix seems to now use the second moment rather than the covariance (i.e. d(i) x d(i+1) instead of [ d(i) - mean(d(i)) ] x [ d(i+1) - mean(d(i+i) ] ) or is this not relevant? It seems to give computationally different outcomes, although perhaps under the null hypothesis it should not matter?

(2) Why aren't Bartlett weights used to reduce the weight of covariances that are only partially overlapping, as in Newey-West (1987)?

arbur liu

Frantisek Brazdik

William Schaefer

Semin Ibisevic

The latest update (1.2) fixes the issue as pointed out by several users (Frantisek, Mark, Dmitrii, etc.)

Frantisek Brazdik

taking longer horizons triggers occurance of negative variance estimator.

Change proposed by Mark, should be taken in to account.

Jaime Trujillo

Please see dmtest_modified(e1, e2, h) for a slight modification of the test as suggested by Harvey, Leybourne, and Newbold (1997).

Panty

Does anyone has a code for the Clark and West (2006) test?? Or is it possible to build it using the DM test code?? Thanks

Mark

I believe there is one minor problem with the computation. You are using the "cov" function on the vectors d(1+i:T) and d(1:T-i) to compute the covariance at lag i. However, this method will normalize by T-i-1 (per the Matlab documentation). To be consistent with Newey-West and Diebold-Mariano you would want to normalize by T, i.e. assume zero covariance at 'unobserved' lags. I think something like gamma(i) = d(1+i:T)' * d(1:T-i) ./ T would be more appropriate.

Dmitrii

Further investigation showed that the formulas agree with the original formulas by Diabold-Mariano 1995. The problem is that in some instances the variance becomes negative and the value of the test statistics computed in the script is a complex number and expressions like T<-1.96 and T>1.96 are evaluated to false automatically without even generating a warning. This could be very misleading.

Dmitrii

The variance estimator for mean(d) is wrong. It gives negative values in some instances.

MATLAB Release Compatibility
Created with R2010a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Acknowledgements

Inspired: dmtest_modified(e1, e2, h)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!