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.
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.
Semin Ibisevic (2021). Diebold-Mariano Test Statistic (https://www.mathworks.com/matlabcentral/fileexchange/33979-diebold-mariano-test-statistic), MATLAB Central File Exchange. Retrieved .
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)?
The latest update (1.2) fixes the issue as pointed out by several users (Frantisek, Mark, Dmitrii, etc.)
taking longer horizons triggers occurance of negative variance estimator.
Change proposed by Mark, should be taken in to account.
Please see dmtest_modified(e1, e2, h) for a slight modification of the test as suggested by Harvey, Leybourne, and Newbold (1997).
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
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.
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.
The variance estimator for mean(d) is wrong. It gives negative values in some instances.
Inspired: dmtest_modified(e1, e2, h)
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!