*
* @GNewbold actual f1 f2 start end
* Granger-Newbold forecast comparison test
*
* Parameters:
*   actual     series of actual data
*   f1         first set of forecasts
*   f2         second set of forecasts
*   start end  range to analyze (common range of f1, f2 and actual by default)
*
* Reference:
*   Granger and Newbold(1973), "Some Comments on the Evaluation of Economic
*   Forecasts", Applied Economics, vol. 5, pp. 35-47.
*
* Revision Schedule:
*   01/2004 Written by Tom Doan, Estima
*
procedure GNewbold actual f1 f2 start end
type series actual f1 f2
type integer start end
*
local integer startl endl
local series x z
local real gnstat sign12 sign21
*
*  Figure out the range if not supplied
*
inquire(reglist) startl<<start endl<<end
# actual f1 f2
*
* Compute the difference and the sum of the forecast errors
*
set x startl endl = f2-f1
set z startl endl = 2*actual-f1-f2
cmom(nocenter,corrs)
# x z
compute gnstat=%cmom(1,2)/sqrt((1-%cmom(1,2)**2)/(%nobs-1))
compute sign12=.5*%ttest(gnstat,%nobs-1)
if gnstat>0.0
   compute sign12=1-sign12
compute sign21=1-sign12
*
display "Granger-Newbold Forecast Comparison Test"
display "Forecasts of" %l(actual) "over" %datelabel(startl) "to" %datelabel(endl)
*
display "Forecast 1:" %l(f1)
display "Test Statistic" gnstat "P-Value for 1=2 vs 1 better than 2" sign12
display "Forecast 2:" %l(f2)
display "Test Statistic" -gnstat "P-Value for 1=2 vs 2 better than 1" sign21
compute %cdstat=gnstat
end

