/* This Monte Carlo program generates forecasts for application in Diebold-Mariano tests. */ data mc; u1=0;f11=0;f22=0;a=0.7; do t = -100 to 100; actual=rannor(11111); u1=rannor(123456); u2=rannor(654321); f1 = a*f11 + u1; f2 = a*f22 + u2*2; e1=actual-f1; e2=actual-f2; if t > 0 then output; f11=f1; f22=f2; end; DATA ERRORS; SET mc; abse1=abs(e1); abse2=abs(e2); e12 = e1**2.0; e22 = e2**2.0; e1pe2 = e1 + e2; e1me2 = e1 - e2; ae1mae2 = abse1 - abse2; e12me22 = e12 - e22; PROC UNIVARIATE DATA = ERRORS NOPRINT; VAR ABSE1 E12 ABSE2 E22; OUTPUT MEAN = MAE1 MSE1 MAE2 MSE2 OUT = RESULTS; /* Print out forecasting accuracy measures of competing methods. */ PROC PRINT DATA = RESULTS; VAR MAE1 MSE1 MAE2 MSE2; TITLE1 ' '; TITLE2 'FORECASTING ACCURACY MEASURES OF COMPETING METHODS'; TITLE3 'FORECAST HORIZON = 1, METHOD 1 = TF, METHOD 2 = BJ'; /* Diebold-Mariano Test for Significant Difference in MAEs. */ /* AR(1) is the best model for the variable ae1mae2. Examine the significance of the mean of the AR(1) model. */ /* Since the mean of the AR(1) Model is significantly less than zero, we conclude that the population MAE of the first forecasting method is less than the population MAE of the second forecasting method. */ proc arima data=errors; identify var=ae1mae2; estimate p=0 q=0; estimate p=1 q=0; estimate p = 2 q = 0; estimate p=0 q=1; estimate p = 0 q = 2; estimate p = 1 q = 1; title 'Diebold-Mariano Test for Significant Difference in MAEs'; run; /* Diebold-Mariano Test for Significant Difference in MSEs. */ /* AR(1) is the best model for the variable e12me22. Examine the significance of the mean of the AR(1) model. */ /* Since the mean of the AR(1) Model is significantly less than zero, we conclude that the population MSE of the first forecasting method is less than the population MSE of the second forecasting method. */ proc arima data=errors; identify var=e12me22; estimate p=0 q=0; estimate p=1 q=0; estimate p = 2 q = 0; estimate p=0 q=1; estimate p = 0 q = 2; estimate p = 1 q = 1; title 'Diebold-Mariano Test for Significant Difference in MSEs'; run;