MATLAB Answers

# Variable delays in NARX net

4 views (last 30 days)
mathbourne on 15 Jul 2016
Commented: Greg Heath on 16 Jul 2016
Using the Neural Network Toolbox, I would like to forecast the hourly sales from a shop for a year. The shop itself only gives the sales data 18 hours after it happened.
Another shop of the same type also gives the data 18 hours after it happened but in the meantime, they give a forecast. Since the sales between the two are correlated, I wanna use the sales from the other shop as an external input in a NARXNET.
To train my net, I have the choice of using the real sales of the other shop; b_sales, or the forecast; b_sales_forecast.
What I would really like to do however is use all the information.
At each timestep, I would like to have a compound of the 2 variables; input delays from 0 to 18 would be b_sales_forecast and from 19 to 48 would be b_sales.
I thought I would find a way to do this within the 'tonndata' or the 'preparets' function but I found nothing.
This is my code :
dataset = [dummyvar(date_string.Month) dummyvar(date_string.Hour+1) b_sales_forecast];
X = tonndata(dataset,false,false);
T = tonndata(a_sales,false,false);
trainFcn = 'trainlm';
inputDelays = 0:48;
feedbackDelays = 18:48;
hiddenLayerSize = 25;
net1 = narxnet(inputDelays,feedbackDelays,hiddenLayerSize,'open',trainFcn);
[x,xi,ai,t] = preparets(net1,X,{},T);
net1.divideParam.trainRatio = 70/100;
net1.divideParam.valRatio = 15/100;
net1.divideParam.testRatio = 15/100;
[net1,tr] = train(net1,x,t,xi,ai);
y = net1(x,xi,ai);
output=cell2mat(y)';
Thank you for your time.

#### 1 Comment

Greg Heath on 16 Jul 2016
Insufficient information and explanation.

Sign in to comment.

Translated by