***forecast correction model for the LIV survey * * This is program LIV_FIEbias_1Qlhs_5yr_psig_08Dec.prg on 12/8/08 * It runs forecast improvement exercises * Uses 1Q actual on LHS of FIE equation * Modified to make it easier to change number of obs in first regression * Modifed to do DM test * Modified to just do FIE in periods with p<0.05; otherwise use survey * cal 1947 1 2 alloc 0 2010:2 * declare series newfor declare series pinf dum source(noecho) c:\Data\msetest2.src * set some parameters * ffirst = first forecast date * flast = last forecast date * afirst = first actual date * alast = last actual date * compute ffirst = 1971:1 ; * first forecast compute flast = 2007:2 ; * last forecast compute afirst = 1965:2 ; * first actual compute alast = 2007:2 ; * last actual compute aflast = 2006:2 ; * last actual minus one year for lag in forecast compute ffs = 24 ; * when ffs = 24, you have 20 observation in the first fie regression * open data c:\data\LIVPIE1.xls data(format=xls,org=obs) ffirst flast livpie1 * * First, test capturing the right actuals * open data c:\data\LIV_actuals_p_08May.xls data(format=xls,org=obs,select=2) afirst alast actual_l_q5 actual_1q_q5 actual_1y_q5 $ actual_3y_q5 actual_pb_q5 * print(dates) afirst flast livpie1 actual_l_q5 actual_1q_q5 actual_1y_q5 $ actual_3y_q5 actual_pb_q5 * * * * * *************************************************** * * * Part 4. Create improved forecasts * * * * * *************************************************** * * * * Here's the new part * * Here is the setup for getting the dates with significant p-values from other program set dum ffirst+ffs flast = 0.0 set dum 1979:1 1979:2 = 1.0 set dum 1985:1 2000:1 = 1.0 set dum 2001:2 2003:1 = 1.0 * * do fdate = ffirst+ffs, flast compute fdate5 = fdate - 5 * set pinf / = actual_1q_q5(t+2) * display 'fdate = ' fdate * display 'ffirst = ' ffirst * compute fdate1 = fdate - 1 print(dates) ffirst fdate5 pinf livpie1 set perror / = pinf - livpie1 linreg perror ffirst fdate5 # constant * set newfor fdate fdate = (dum*%beta(1)) + livpie1(fdate) print(dates) fdate fdate newfor livpie1 display 'alpha= ' %beta(1) * * end do fdate * *************************************************** * * * Part 5. Calculate RMSEs * * * * * *************************************************** set z1 = actual_1q_q5 * display ' ' display 'Forecast improvement exercise' display 'Actuals are 1Q' display ' ' * compute ffirsts = ffirst + ffs compute flast5 = flast - 5 * set pi1 / = z1(t+2) set e = pi1 - livpie1 set newerror = pi1 - newfor print(dates) ffirsts flast5 pi1 livpie1 newfor e newerror * ***descriptive statistics of forecast errors smpl ffirsts flast5 * * display 'Statistics for survey forecast error' statistics e * * display 'Statistics for improved survey forecast error' statistics newerror * * display ' ' * ***Calculate RMSE * compute ts = %nobs compute ae = %dot(e,e) compute rmsee = sqrt(ae/ts) *compute rmse(2,1) = rmsee display 'This is actuals = 1Q' display ' ' display 'Root Mean Square Forecast Error for survey =' rmsee * compute ts = %nobs compute ae = %dot(newerror,newerror) compute rmsee = sqrt(ae/ts) *compute rmse(2,1) = rmsee display 'Root Mean Square Forecast Error for improvement to survey =' rmsee * * @msetest2(nopictures) livpie1 newfor pi1 ffirsts flast5 3 p11 p1 *