''' Forecast comparison %path="D:\GEER\Resu.lts\" cd {%path} %esmpl="2000q2 2015q3" %list="ip ord pmi ifoc ifoe ifol esi zewl zewe dax is_m ar" %grc="ip ord ifoc pmi esi zewl dax" cd %path wfcreate(wf=wf_forecast) q 1991 2015 %allg="" !count=1 for !mrel=0 to 3 for %B real final open d_{%B}vl2num2mrel{!mrel} for %ind {%list} %vari1="forh1_" + %ind + "_2_mr" + @str(!mrel) %vari2=%B +"_fh1_" + %ind + "_mr" + @str(!mrel) %wf1="d_" + %B +"vl2num2mrel" + @str(!mrel) %wf2="wf_forecast" %C=%wf1+"::Quartal\"+%vari1 %D=%wf2+"::Untitled\"+%vari2 copy %C %D next if !count=1 then for %Z first final %C=%wf1+"::Quartal\bip_" + %Z %D=%wf2+"::Untitled\bip_" + %Z copy %C %D next endif close d_{%B}vl2num2mrel{!mrel} next for %ind {%list} %yv="final_fh1_" + %ind + "_mr" + @str(!mrel) %xv="real_fh1_" + %ind + "_mr" + @str(!mrel) delete(noerr) gr_{%ind}_mrel{!mrel} group gr_{%ind}_mrel{!mrel} {%xv} {%yv} delete(noerr) tab_eq tab_corr equation eq_help.ls(n) {%xv}-{%yv} c {%yv} freeze(tab_eq) eq_help.results 'Mean equation eq_mean.ls(n) {%xv}-{%yv} c 'Standard deviations: !varr=@vars({%xv})/@vars({%yv}) freeze(tab_corr) gr_{%ind}_mrel{!mrel}.cov(outfmt=single) rcorr rprob if !mrel=0 then delete(noerr) tab_fc_{%ind} table(12,5) tab_fc_{%ind} setline(tab_fc_{%ind},2) tab_fc_{%ind}(3,1)="const" tab_fc_{%ind}(4,1)="b" tab_fc_{%ind}(5,1)="p-val" setline(tab_fc_{%ind},6) tab_fc_{%ind}(7,1)="Spearman rank corr" tab_fc_{%ind}(8,1)="Mean diff" tab_fc_{%ind}(9,1)="p-value" tab_fc_{%ind}(10,1)="Var ratio" endif tab_fc_{%ind}(3,1+!mrel+1)=@val(tab_eq(11,2)) tab_fc_{%ind}(4,1+!mrel+1)=@val(tab_eq(12,2)) tab_fc_{%ind}(5,1+!mrel+1)=@val(tab_eq(21,2)) tab_fc_{%ind}(1,1+!mrel+1)="M=" + @str(!mrel) tab_fc_{%ind}(7,1+!mrel+1)=@val(tab_corr(12,2)) tab_fc_{%ind}(8,1+!mrel+1)=eq_mean.@coefs(1) tab_fc_{%ind}(9,1+!mrel+1)=eq_mean.@pval(1) tab_fc_{%ind}(10,1+!mrel+1)=!varr next !count=!count+1 next for %ind {%list} group gr_{%ind}all gr_{%ind}_mrel0 gr_{%ind}_mrel1 gr_{%ind}_mrel2 gr_{%ind}_mrel3 delete(noerr) ga_sc_{%ind} freeze(ga_sc_{%ind}) gr_{%ind}all.scatpair ga_sc_{%ind}.setelem(1) linecolor(@rgb(0,0,0)) ga_sc_{%ind}.setelem(2) symbol(STAR) linecolor(@rgb(128,128,128)) ga_sc_{%ind}.setelem(3) symbol(FILLEDSQUARE) linecolor(@rgb(192,192,192)) ga_sc_{%ind}.setelem(4) symbol(FILLEDTRIUP) linecolor(@rgb(232,232,232)) ga_sc_{%ind}.draw(line, left) 0 ga_sc_{%ind}.draw(line, bottom) 0 ga_sc_{%ind}.legend -display ga_sc_{%ind}.axis(l) range(-4,3) ga_sc_{%ind}.axis(b) range(-4,3) ga_sc_{%ind}.addtext(t,font=14) %ind ga_sc_{%ind}.addtext(b,font=12) "Real-time" ga_sc_{%ind}.addtext(l,font=12) "Final" %allg=%allg + "ga_sc_" + %ind + " " next graph grall.merge {%allg} grall.align(3,1.5,1) '================================================================= 'Calculate statistic based on contingence tables (negative growth): pagecreate(page=cross) u 4 pageselect Untitled for !mrel=0 to 3 for %B real final for %ind {%list} for %comp bip_first bip_final if %comp="bip_first" then %cp="f" endif if %comp="bip_final" then %cp="l" endif %tab="tabc_" + %ind + "_"+ "mr" + @str(!mrel) + %B + "_" + %cp delete(noerr) {%tab} table(8,7) {%tab} {%tab}(1,2)="<0" {%tab}(1,3)=">=0" setline({%tab},2) {%tab}(3,1)="<0" {%tab}(4,1)=">=0" smpl {%esmpl} !tobs=@obssmpl 'first case smpl {%esmpl} if {%B}_fh1_{%ind}_mr{!mrel}<0 and {%comp}<0 {%tab}(3,2)=@obssmpl/!tobs*100 !sum=@obssmpl/!tobs*100 !tab32=@obssmpl smpl {%esmpl} if {%B}_fh1_{%ind}_mr{!mrel}<0 and {%comp}>=0 {%tab}(3,3)=@obssmpl/!tobs*100 !tab33=@obssmpl 'second case smpl {%esmpl} if {%B}_fh1_{%ind}_mr{!mrel}>=0 and {%comp}<0 {%tab}(4,2)=@obssmpl/!tobs*100 !tab42=@obssmpl smpl {%esmpl} if {%B}_fh1_{%ind}_mr{!mrel}>=0 and {%comp}>=0 {%tab}(4,3)=@obssmpl/!tobs*100 !sum=!sum+@obssmpl/!tobs*100 !tab43=@obssmpl smpl {%esmpl} !tab_r1=!tab32+!tab33 !tab_r2=!tab42+!tab43 !tab_c1=!tab32+!tab42 !tab_c2=!tab33+!tab43 'hit rate: !h=!tab32/!tab_c1 !f=!tab33/!tab_r1 !pss=!h-!f !csi = !tab32/(!tab_r1+!tab42) {%tab}(6,1)="Peirce skill score:" {%tab}(6,3)=!pss {%tab}(7,1)="Critical Success Index:" {%tab}(7,3)=!csi pageselect cross series csi_{%ind}_{%B}_{%cp} csi_{%ind}_{%B}_{%cp}(!mrel+1)=!csi pageselect Untitled next 'comp next ' ind next 'real/final next 'info '============================================= pageselect cross alpha lab %grc="ip ord ifoc pmi esi zewl dax" lab(1)="all 3 months available" lab(2)="2 months available" lab(3)="1 month available" lab(4)="no month of the current quarter available" for %A real final for %B f l delete(noerr) gr_csi_{%A}_{%B} ga_csi_{%A}_{%B} gam_* group gr_csi_{%A}_{%B} for %C {%grc} gr_csi_{%A}_{%B}.add csi_{%C}_{%A}_{%B} next graph ga_csi_{%A}_{%B}.bar gr_csi_{%A}_{%B} ga_csi_{%A}_{%B}.setobslabel(series) lab ga_csi_{%A}_{%B}.axis(left) range(0,0.7) if %A="final" then ga_csi_{%A}_{%B}.legend -display ga_csi_{%A}_{%B}.addtext(t, font(14pt)) "pseudo real-time" else ga_csi_{%A}_{%B}.addtext(t,font(14pt)) "real-time" endif ga_csi_{%A}_{%B}.setelem(5) fillhatch(DIAGCROSS) ga_csi_{%A}_{%B}.setelem(6) fillhatch(FDIAGONAL) ga_csi_{%A}_{%B}.setelem(7) fillhatch(CROSS) !il=1 for %C {%grc} ga_csi_{%A}_{%B}.setelem(!il) legend(%C) !il=!il+1 next next next graph gam_csif.merge ga_csi_real_f ga_csi_final_f graph gam_csil.merge ga_csi_real_l ga_csi_final_l gam_csif.align(2,1,1) gam_csil.align(2,1,1) gam_csil.axis(l) range(0,0.5) gam_csif.legend position(4.5,4.5) gam_csil.legend position(4.5,4.5)