Diebold_Mariano Test

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt

donihue
Posts: 137
Joined: Wed Oct 07, 2009 8:51 am

Diebold_Mariano Test

Postby donihue » Wed Mar 30, 2011 5:07 am

Hello,

Would anyone have an EViews code to produce the Diebold-Mariano Predictive Accuracy Test (Diebold, F.X. and R. S. Mariano, "Comparing Predictive Accuracy", J. Bus and Ec Stat, Vol. 13, No. 3, July 1995)?

Regards
Donihue

Savy
Posts: 4
Joined: Fri Apr 01, 2011 1:15 am

Re: Diebold_Mariano Test

Postby Savy » Fri Apr 01, 2011 2:13 am

Hi donihue

In its simple form, the DM test can be calculated by regressing the difference of the loss functions (squared or absolute error) on a constant using Newey-West standard errors

Code: Select all

'fc1: Forecast 1
'fc2: Forecast 2
'r: Realised Data

' MSE
es_fc1 = (fc1 - r)^2
es_fc2 = (fc2 - r)^2
genr d_squaredloss = es_fc1 - es_fc2

' MAE
ea_fc1 = @abs(fc1 - r)
ea_fc2 = @abs(fc2 - r)
genr d_absloss = ea_fc1 - ea_fc2

' DM test
equation dm_squaredloss.ls(n) d_squaredloss c
equation dm_abs.ls(n) d_absloss c


However, be aware of certain limits of the DM test. For the small sample bias correction, check
Harvey, Leybourne and Newbold, "Testing the equality of prediction mean squared errors", 1998
and for a more general discussion, check e.g.
Giacomini and White, "Tests of Conditional Predictive Ability", 2006

Best
Savy

donihue
Posts: 137
Joined: Wed Oct 07, 2009 8:51 am

Re: Diebold_Mariano Test

Postby donihue » Fri Apr 01, 2011 2:38 am

Many thanks, Savy. That is very helpful indeed.

Regards
Donihue

stasibab
Posts: 55
Joined: Sun May 08, 2011 2:20 pm

Re: Diebold_Mariano Test

Postby stasibab » Mon Sep 12, 2011 9:00 am

I am trying to use this code for the DM test but I get the error as in the image...
Could you help me?
Attachments
dmtest.jpg
dmtest.jpg (95.39 KiB) Viewed 11270 times

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 12419
Joined: Tue Sep 16, 2008 5:38 pm

Re: Diebold_Mariano Test

Postby EViews Gareth » Mon Sep 12, 2011 9:15 am

Put a genr in front of the line that sets them.
Follow us on Twitter @IHSEViews

stasibab
Posts: 55
Joined: Sun May 08, 2011 2:20 pm

Re: Diebold_Mariano Test

Postby stasibab » Mon Sep 12, 2011 9:36 am

Thanx Gareth,

I 've done what you said, I pressed run without having any errors but I do not get any results...

Do I have to do something else to see the results?

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 12419
Joined: Tue Sep 16, 2008 5:38 pm

Re: Diebold_Mariano Test

Postby EViews Gareth » Mon Sep 12, 2011 10:07 am

I don't know enough about the test to say what the results should be. The code generates an equation object, which will be in your workfile. Which of the equation results you need to look at though, I don't know. I'm sure you can figure that bit out though.
Follow us on Twitter @IHSEViews

stasibab
Posts: 55
Joined: Sun May 08, 2011 2:20 pm

Re: Diebold_Mariano Test

Postby stasibab » Mon Sep 12, 2011 10:19 am

Dear Gareth, the problem is that I do not get the workfile either...
any ideas why? this is my data

when I press run and I get a new box 'run program' I should just press 'ok' right?

Sorry if the questions are stupid, I am quite a rookie...
Attachments
r.xlsx
(48.55 KiB) Downloaded 250 times
fc2.xlsx
(48.61 KiB) Downloaded 230 times
fc1.xlsx
(48.62 KiB) Downloaded 174 times

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 12419
Joined: Tue Sep 16, 2008 5:38 pm

Re: Diebold_Mariano Test

Postby EViews Gareth » Mon Sep 12, 2011 11:36 am

Your screenshot clearly indicates that you have a workfile open.
Follow us on Twitter @IHSEViews

stasibab
Posts: 55
Joined: Sun May 08, 2011 2:20 pm

Re: Diebold_Mariano Test

Postby stasibab » Mon Sep 12, 2011 11:39 am

Excuse me bad writing, I meant I do not get the new object into the workfile!

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 12419
Joined: Tue Sep 16, 2008 5:38 pm

Re: Diebold_Mariano Test

Postby EViews Gareth » Mon Sep 12, 2011 11:41 am

You should have an equation object called dm_squaredloss and one called dm_abs
Follow us on Twitter @IHSEViews

stasibab
Posts: 55
Joined: Sun May 08, 2011 2:20 pm

Re: Diebold_Mariano Test

Postby stasibab » Mon Sep 12, 2011 11:44 am

Sorry I run it, I do not get any errors but nothing is added in my workfile... Strange?

Abdelrazzaq
Posts: 13
Joined: Thu Mar 27, 2014 9:17 am

Re: Diebold_Mariano Test

Postby Abdelrazzaq » Tue Sep 30, 2014 8:11 am

I did run the test and had the results. I think the result is not valid enough . t statistic. please find attached.
Attachments
aexorg.wf1
(562.27 KiB) Downloaded 261 times

Abdelrazzaq
Posts: 13
Joined: Thu Mar 27, 2014 9:17 am

Re: Diebold_Mariano Test

Postby Abdelrazzaq » Wed Oct 01, 2014 1:42 am

please give me some attention


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 3 guests