By the way, this is an interesting example. Perhaps it's something I could use in my undergraduate econometrics class. If you wouldn't mind, can you say a little more about where the data is from and what the objective of the forecast is?
The data come from the sales made in the region of Valparaíso Chile.
The interest is not in finally predicting the next day's demand.
The objective is as follows: You have a matrix (that I built) ("_dias_piso") which delivers for the period of 2017 day by day the number of days that the current stock can support the sales made in the future, ( This matrix is constructed with the stock series of each sku and accumulated demand). Then the matrix "_dias_piso" are the actual days in which the stock of a certain day can withstand the future demands.
I constructed matrices for each sku and each day of a forecast ("dias_piso") using the series of sku {! I} and different models, I compare it with the sample quasivariance.
I am not a programmer but the code I can do is something like this:
smpl @all
matrix(114, 84) _dias_piso
for !j = 1 to 84
for !i = 1 to 114
%demanda_acum = @str(!i) + " " + @str(114)
series pisos = @cumsum(demandasku{!j}, %demanda_acum) <= @elem(stocksku{!j}, !i)
_dias_piso(!i, !j) = @sum(pisos)
next
next
for !j= 2 to 6
for !i =1 to 84
group _SKU
_SKU.add sku{!i}
group _STOCKSKU
_STOCKSKU.add STOCKSKU{!i}
for !k=7 to 12
group _Modelo{!k}
equation Reg_Simple_eq1_sku{!i}.ls sku{!i} c corr
forecast sku{!i}_7
equation Reg_Simple_eq_sku{!i}.ls sku{!i} c corr corr^2 @expand(mes, @droplast) lunes miercoles viernes
forecast sku{!i}_8
equation AR1_eq_sku{!i}.ls sku{!i} c corr sku{!i}(-1)
forecast sku{!i}_9
equation AR2_eq_sku{!i}.ls sku{!i} c corr sku{!i}(-1) sku{!i}(-2)
forecast sku{!i}_10
equation AR3_eq_sku{!i}.ls sku{!i} c corr sku{!i}(-1) sku{!i}(-2) sku{!i}(-3) @expand(mes, @droplast) lunes martes miercoles jueves viernes
forecast sku{!i}_11
equation Salida_eq_sku{!i}.ls sku{!i} c @expand(mes, @droplast) lunes martes miercoles jueves viernes
forecast sku{!i}_12
_Modelo{!k}.add sku{!i}_{!k}
next
for !k=17 to 17
group _modelo{!k}
equation xxxx{!i}.ls sku{!i} corr corr^2 corr^3 @expand(mes, @droplast)
forecast sku{!i}_17
_modelo{!k}.add sku{!i}_{!k}
next
group _Modelo{!j}
series Moving_Average_{!j}sku{!i} =( @movsum(sku{!i}, {!j}) ) / {!j}
_Modelo{!j}.add Moving_Average_{!j}sku{!i}
for !l=13 to 16
group _Modelo{!l}
smooth(s) sku{!i} SE13_sku{!i} [4]
smooth(d) sku{!i} SE14_sku{!i} [4]
smooth(n) sku{!i} SE15_sku{!i} [4]
smooth(a) sku{!i} SE16_sku{!i} [4]
_Modelo{!l}.add SE{!l}_sku{!i}
next
next
next
'-----------------------------------------------------------------------------------------------------------------------------------------------------
for !m=2 to 17
matrix(97, 84) _matrix!m
for !c =1 to 84
for !r =1 to 97
_matrix!m(!r, !c) = _stocksku (!c) (!r) / _modelo!m (!c) (!r + 911)
next
next
next
'-----------------------------------------------------------------------------------------------------------------------------------------------------
matrix(97, 84) _diaspiso
for !c=1 to 84
for !r=1 to 97
_diaspiso(!r, !c) = _dias_piso(!r, !c)
next
next
'-----------------------------------------------------------------------------------------------------------------------------------------------------
for !m=2 to 17
matrix(97,84) _error!m
_error!m = _diaspiso - _matrix!m
next
'----------------------------------------------------------------------------------------------------------------------------------------------------
for !m=2 to 17
matrix _t!m= @transpose(@cmean(_error!m))
matrix(97, 84) _ep!m
for !c=1 to 84
for !r=1 to 97
_ep!m(!r,!c) = _t!m(1, !c)
next
next
next
'--------------------------------------------------------------------------------------------------------------------------------------------------
for !m=2 to 17
matrix(97, 84) _x!m
matrix(97, 84) _z!m
_x!m = _error!m - _ep!m
for !c=1 to 84
for !r=1 to 97
matrix _z!m(!r, !c) = _x!m(!r, !c) * _x!m(!r, !c)
next
next
next
for !m=2 to 17
matrix(1, 84) _w!m
matrix(16, 84) _evaluador
matrix _w!m = @transpose(@csum(_z!m)/96)
for !c=1 to 84
_evaluador(!m-1, !c) = _w!m(1, !c)
next
next
matrix __best_model = @cimin(_evaluador)
matrix __resultados = @sort(@uniquevals(__best_model),"a")
matrix(__resultados.@rows, 2) __resultados
for !i = 1 to __resultados.@rows
!iden = 0
for !c = 1 to 84
if __best_model(!c, 1) = __resultados(!i, 1) then
!iden = 1 + !iden
endif
next
__resultados(!i, 2) = !iden
next