Computing Forecast Evaluation Criteria

For posting your own programs to share with others

Moderators: EViews Gareth, EViews Moderator

trubador
Did you use forum search?
Posts: 1518
Joined: Thu Nov 20, 2008 12:04 pm

Computing Forecast Evaluation Criteria

Postby trubador » Thu May 14, 2009 5:44 am

Below is a short piece of code I've written as a subroutine for computing the forecast error statistics that EViews commonly reports. Although you may find it useful, it has not been tested/improved enough and is intended only to help you in obtaining these statistics effectively, where EViews does not automatically produce. Using the code is at your own risk...

Code: Select all

'y is the dependent variable
'yf is the forecasted values of the dependent variable
's is the forecast sample and should be defined carefully beforehand (e.g. sample s 1997m04 2009m04)

sample my_sample beginning end
call forper(my_series,my_forecasts,my_sample)


subroutine forper(series y,series yf,sample s)

table(7,2) criteria
criteria.setwidth(A) 20
criteria.setjust(1,A,7,B) left
criteria.setindent(5,A,7,A) 8

smpl s
!h = @obssmpl

series ratio = yf/y
series one = 1
series dif= yf - y

!RMSE = @sqrt((@sumsq(dif))/!h)
!MAE = (@sum(@abs(dif)))/!h
!MAPE = 100*(@sum(@abs(one-ratio)))/!h
!THEIL = !RMSE / ( @sqrt((@sumsq(y))/!h) + @sqrt((@sumsq(yf))/!h))
!biasprop = (@mean(yf) - @mean(y))^2 / !RMSE^2
!varianceprop = (@sqrt(@var(yf)) - @sqrt(@var(y)))^2 / !RMSE^2
!covarianceprop = 2*(1-@cor(yf,y))*@sqrt(@var(yf))*@sqrt(@var(y)) / !RMSE^2

!i=1
for %c RMSE MAE MAPE THEIL Biasprop Varianceprop Covarianceprop
  criteria(!i,1)=%c
  %r = "!"+%c
  criteria(!i,2)={%r}
  !i=!i+1
next
show criteria

smpl @all
delete s ratio one dif
endsub

Return to “Program Repository”

Who is online

Users browsing this forum: No registered users and 12 guests