Research Article

Forecasting of Chinese E-Commerce Sales: An Empirical Comparison of ARIMA, Nonlinear Autoregressive Neural Network, and a Combined ARIMA-NARNN Model

Box 1

% solved by NARNN based on matlab
% rawdata is a weekly sales data of chocolate of the JD.COM
rawdata=data
T = tonndata(rawdata,false,false);
%  ‘trainlm’ is usually fastest.
%   ‘trainbr’ takes longer but may be better for challenging problems.
%   ‘trainscg’ uses less memory. NTSTOOL falls back to this in low memory situations.
trainFcn = ‘trainbr’; % Bayesian Regularization
feedbackDelays = 1:3;
hiddenLayerSize = 17;
net = narnet(feedbackDelays,hiddenLayerSize, ‘open’,trainFcn);
net.input.processFcns = ‘removeconstantrows’, ‘mapminmax’;
= preparets(net,,,T);
net.divideFcn = ‘dividerand’; % Divide data randomly
net.divideMode = ‘time’; % Divide up every value
net.divideParam.trainRatio = 70/100;
net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 15/100;
net.performFcn = ‘mse’;
net.plotFcns = ‘plotperform’, ‘plottrainstate’, ‘plotresponse’,...
‘ploterrcorr’, ‘plotinerrcorr’;
= train(net,x,t,xi,ai);
y = net(x,xi,ai);
e = gsubtract(t,y);
performance = perform(net,t,y)
trainTargets = gmultiply(t,tr.trainMask);
valTargets = gmultiply(t,tr.valMask);
testTargets = gmultiply(t,tr.testMask);
trainPerformance = perform(net,trainTargets,y)
valPerformance = perform(net,valTargets,y)
testPerformance = perform(net,testTargets,y)
view(net)
% Plots
% Uncomment these lines to enable various plots.
%figure, plotperform(tr)
%figure, plottrainstate(tr)
%figure, plotresponse(t,y)
%figure, ploterrcorr(e)
%figure, plotinerrcorr(x,e)
netc = closeloop(net);
= preparets(netc,,,T);
yc = netc(xc,xic,aic);
perfc = perform(net,tc,yc)
= preparets(net,,,T);
= net(x1,xio,aio);
= closeloop(net,xfo,afo);
= netc(cell(0,5),xic,aic);
nets = removedelay(net);
= preparets(nets,,,T);
ys = nets(xs,xis,ais);
stepAheadPerformance = perform(net,ts,ys)
genFunction(net, ‘myNeuralNetworkFunction’);
y = myNeuralNetworkFunction(x,xi,ai);
end
if (false)
genFunction(net, ‘myNeuralNetworkFunction’, ‘MatrixOnly’, ‘yes’);
x1 = cell2mat(x(1,:));
xi1 = cell2mat(xi(1,:));
y = myNeuralNetworkFunction(x1,xi1);
end
if (false)
gensim(net);
end