dmtest function

Computes Diebold-Mariano Test.

Computes Diebold-Mariano Test.

This is a wrapper for dm.test from forecast package. This function computes the original Diebold-Mariano test.

Details

The null hypothesis is that the two methods have the same forecast accuracy. This function assumes that one-step ahead forecasts are compared and the second power is used in the loss function (see dm.test). "The Diebold-Mariano (DM) test was intended for comparing forecasts; it has been, and remains, useful in that regard. The DM test was not intended for comparing models." (Diebold, 2015)

dmtest(y,f)

Arguments

  • y: vector of the forecasted time-series
  • f: matrix of the predicted values from various methods, forecasts are ordered in rows, the first row should correspond to the method that is compared with alternative ones (corresponding to subsequent rows)

Returns

matrix, first column contains tests statistics, next p-values are given for the alternative hypothesis that alternative forecasts have different accuracy than the compared forecast, alternative forecasts are less accurate and alternative forecasts have greater accuracy, tests outcomes for different forecasts are ordered by rows

Examples

wti <- crudeoil[-1,1] drivers <- (lag(crudeoil[,-1],k=1))[-1,] ld.wti <- (diff(log(wti)))[-1,] ld.drivers <- drivers[-1,] ld.drivers[,c(4,6)] <- (diff(drivers[,c(4,6)]))[-1,] ld.drivers[,c(1:2,5,7)] <- (diff(log(drivers[,c(1:2,5,7)])))[-1,] ld.drivers[,c(3,6)] <- ld.drivers[,c(3,6)]/100 m <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.90,initvar=10,initial.period=241) m <- m$y.hat a <- altf2(y=ld.wti,x=ld.drivers,d=TRUE,initial.period=241) a <- a$y.hat a <- matrix(unlist(a),nrow=length(a),byrow=TRUE) fc <- rbind(m,a) dm <- dmtest(y=as.vector(ld.wti)[-(1:240)],f=fc[,-(1:240)])

References

Diebold, F. X., 2015. Comparing predictive accuracy, Twenty years later: A peersonal perspective on the use and abuse of Diebold-Mariano tests. Journal of Business & Economic Statistics 33 , tools:::Rd_expr_doi("10.1080/07350015.2014.983236") .

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

See Also

hmdmtest, mdmtest.