How to include weight factors for demand forecasting

6 views (last 30 days)
Dear all,
I am working on a demand forecasting model in matlab and have just beginners expertise with the program.
What I am trying to do is give a demand forecast for 7 periods. This forecast is based on the Croston, Syntetos Boyland and moving average principles.
The actual values are given by the vector "original_data" and represent probability values. At the moment the program works, however I would like to include weighting factors to each actual value and base the forecast on these weighted actual values. Logically 5 inspections with all probability 0 says more than just 1 inspection with a probability of 0. The weighting factor for each period is given by the vector "inspected" and represent the number of inspections.
Does anyone know how to include the weighting factors into the forecasting models Croston, Syntetos Boylan and Moving average?
The code:
MATLAB code
% function [Croston, SBA, SBA2,MovingAverage]=w_croston(original_data,c)
clear all; clc; close all;
%forecast using Croston method(including modified Croston)
X = [1:1:7];
original_data = [0, 0.111, 0.5, 0, 0.6, 0.8, 1];
inspected = [9, 9, 2, 0, 5, 15, 1];
c1 = 0.9;
c2 = 0.9;
[a1,a2] = size(original_data);
if a1 ~=1
error('input sample must be like 1*n!--by ww')
end
n=length(original_data);
q=1;
Z(1)=original_data(1); %Demand
sum=original_data(1);
I(1)=1; %Interval
Croston(1)=Z(1)/I(1);
SBA(1) = (1-c1/2)*Z(1)/I(1);
SBA2(1)= (1-c1/2)*Z(1)/(I(1)-c1/2);
for i=2:n
if original_data(i)==0
Z(i)=Z(i-1);
I(i)=I(i-1);
q=q+1;
else
Z(i)=c1*original_data(i)+(1-c1)*Z(i-1);
I(i)=c2*q+(1-c2)*I(i-1);
q=1;
end
Croston(i)=Z(i)/I(i); %Croston method result
SBA(i) = (1-c1/2)*Z(i)/I(i); %Modified croston method result
SBA2(i)=(1-c1/2)*Z(i)/(I(i)-c1/2);
% % Plot fit with data.
% h = plot( X, Croston, original_data );
% set(h,'Color','green','LineWidth',2)
%
% hold on
end
%%Actual Values
original_data = [0, 0.111, 0.5, 0, 0.6, 0.8, 1];
figure( 'Name', 'Quantity' );
ylim ([0 1])
xlim ([0.5 7.5])
hold on
bar(X,original_data,'w')
set(gca, 'XTick',1:1:7, 'XTickLabel',{'FC01' 'FC02' 'FC03','FC04','FC05','FC06','FC07'})
hold on
scatter(X,original_data,75,'k', 'filled')
%%Moving Average
hold on
Movingaverage = smooth(original_data,'moving')
plot(Movingaverage,'g-')
%%Savitzky-Golay filter
hold on
Savitzky = smooth(original_data,'sgolay')
plot(Savitzky,'r-')
%%Croston & SBA
hold on
plot(X,Croston,'b--')
hold on
plot(X,SBA,'k-')
hold on
plot(X,SBA2,'b-')
%%General Figure
grid on
xlabel ('')
ylabel ('Average number per aircraft')
title ('ATA53-10 Probability Croston')
h_legend=legend('FC01-FC07','Actual per aircraft','Moving Average','Savitzky-Golay filter','Croston', 'SBA', 'SBA2', 'Location', 'NorthWest')
get(h_legend,'Position')
h_text = findobj(h_legend,'type','text');
set(h_legend,'FontSize',10)
get(h_legend,'Position')
end
end

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!