'program that imports forecasting results into the M3 data workfile, and computes SMAPES open .\m3c.wf1 %names = "theta forpro forx bjauto auto1 auto2 auto3" pageselect yearly !forclen = 6 !n=645 importmat(name=theta) .\m3forecast.xls range="theta!c1:h645" importmat(name=forpro) .\m3forecast.xls range="ForecastPro!c1:h645" importmat(name=forx) .\m3forecast.xls range="forcX!c1:h645" importmat(name=bjauto) .\m3forecast.xls range="B-J auto!c1:h645" importmat(name=auto1) .\m3forecast.xls range="AutoBox1!c1:h645" importmat(name=auto2) .\m3forecast.xls range="AutoBox2!c1:h645" importmat(name=auto3) .\m3forecast.xls range="AutoBox3!c1:h645" for %nm {%names} vector(!n) smapes_{%nm} next for !i=1 to !n smpl @all statusline !i !k=!i+0 !first = @ilast(n!k)-!forclen+1 !last = !first + !forclen-1 %f = @otod(!first) %l = @otod(!last) smpl {%f} {%l} for %nm {%names} vector temp = {%nm}.@row(!i) mtos(temp, n!k_{%nm}) smapes_{%nm}(!i) = @smape(n!k, n!k_{%nm}) d temp next next pageselect quarterly !forclen = 8 !n=756 importmat(name=theta) .\m3forecast.xls range="theta!c646:j1401" importmat(name=forpro) .\m3forecast.xls range="ForecastPro!c646:j1401" importmat(name=forx) .\m3forecast.xls range="forcX!c646:j1401" importmat(name=bjauto) .\m3forecast.xls range="B-J auto!c646:j1401" importmat(name=auto1) .\m3forecast.xls range="AutoBox1!c646:j1401" importmat(name=auto2) .\m3forecast.xls range="AutoBox2!c646:j1401" importmat(name=auto3) .\m3forecast.xls range="AutoBox3!c646:j1401" for %nm {%names} vector(!n) smapes_{%nm} next for !i=1 to !n smpl @all statusline !i !k=!i+645 !first = @ilast(n!k)-!forclen+1 !last = !first + !forclen-1 %f = @otod(!first) %l = @otod(!last) smpl {%f} {%l} for %nm {%names} vector temp = {%nm}.@row(!i) mtos(temp, n!k_{%nm}) smapes_{%nm}(!i) = @smape(n!k, n!k_{%nm}) d temp next next pageselect monthly !forclen = 18 !n=1428 importmat(name=theta) .\m3forecast.xls range="theta!c1402:t2829" importmat(name=forpro) .\m3forecast.xls range="ForecastPro!c1402:t2829" importmat(name=forx) .\m3forecast.xls range="forcX!c1402:t2829" importmat(name=bjauto) .\m3forecast.xls range="B-J auto!c1402:t2829" importmat(name=auto1) .\m3forecast.xls range="AutoBox1!c1402:t2829" importmat(name=auto2) .\m3forecast.xls range="AutoBox2!c1402:t2829" importmat(name=auto3) .\m3forecast.xls range="AutoBox3!c1402:t2829" for %nm {%names} vector(!n) smapes_{%nm} next for !i=1 to !n smpl @all statusline !i !k=!i+1401 !first = @ilast(n!k)-!forclen+1 !last = !first + !forclen-1 %f = @otod(!first) %l = @otod(!last) smpl {%f} {%l} for %nm {%names} vector temp = {%nm}.@row(!i) mtos(temp, n!k_{%nm}) smapes_{%nm}(!i) = @smape(n!k, n!k_{%nm}) d temp next next pageselect other !forclen = 8 !n=174 importmat(name=theta) .\m3forecast.xls range="theta!c2830:j3003" importmat(name=forpro) .\m3forecast.xls range="ForecastPro!c2830:j3003" importmat(name=forx) .\m3forecast.xls range="forcX!c2830:j3003" importmat(name=bjauto) .\m3forecast.xls range="B-J auto!c2830:j3003" importmat(name=auto1) .\m3forecast.xls range="AutoBox1!c2830:j3003" importmat(name=auto2) .\m3forecast.xls range="AutoBox2!c2830:j3003" importmat(name=auto3) .\m3forecast.xls range="AutoBox3!c2830:j3003" for %nm {%names} vector(!n) smapes_{%nm} next for !i=1 to !n smpl @all statusline !i !k=!i+2829 !first = @ilast(n!k)-!forclen+1 !last = !first + !forclen-1 %f = @otod(!first) %l = @otod(!last) smpl {%f} {%l} for %nm {%names} vector temp = {%nm}.@row(!i) mtos(temp, n!k_{%nm}) smapes_{%nm}(!i) = @smape(n!k, n!k_{%nm}) d temp next next 'collate pagecreate(page=results) u 10 for %nm {%names} copy yearly\smapes_{%nm} results\smapes_{%nm}_y copy quarterly\smapes_{%nm} results\smapes_{%nm}_q copy monthly\smapes_{%nm} results\smapes_{%nm}_m copy other\smapes_{%nm} results\smapes_{%nm}_o vector smapes_{%nm} = @vcat(smapes_{%nm}_y, smapes_{%nm}_q) smapes_{%nm}= @vcat(smapes_{%nm}, smapes_{%nm}_m) smapes_{%nm}= @vcat(smapes_{%nm}, smapes_{%nm}_o) next table smapes smapes(1,1) = "Package" smapes(1,2) = "Mean SMAPE" !rc=2 for %nm {%names} smapes(!rc,1) = %nm smapes(!rc,2) = @mean(smapes_{%nm}) !rc=!rc+1 next show smapes