MATLAB Answers

Closed Loop performance of trained NAR not good enough. Why?

3 views (last 30 days)
Fred on 29 Aug 2018
Hello, I'm using NAR to predict future values of my timeseries, but when I plot response of closed loop network I saw output shifts in time, I could not figure out why. Can anybody help me? Here are my codes, basically most of it generated from ntstool, and some are my modifications.
T = normalizedsolarpower;
N = length(T)
trainFcn = 'trainlm'; % Levenberg-Marquardt backpropagation.
% Create a Nonlinear Autoregressive Network
feedbackDelays = 1:2;
hiddenLayerSize = 10;
net = narnet(feedbackDelays,hiddenLayerSize,'open',trainFcn);
% Prepare the Data for Training and Simulation
[x,xi,ai,t] = preparets(net,{},{},T);
% Setup Division of Data for Training, Validation, Testing
net.divideParam.trainRatio = 70/100;
net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 15/100;
% Train the Network
[net,tr] = train(net,x,t,xi,ai);
% Test the Network
y = net(x,xi,ai);
e = gsubtract(t,y);
performance = perform(net,t,y)
% View the Network
% Closed Loop Network
netc = closeloop(net); = [ ' - Closed Loop'];
[xc,xic,aic,tc] = preparets(netc,{},{},T);
yc = netc(xc,xic,aic);
closedLoopPerformance = perform(net,tc,yc)
ypredic = netc(cell(0,96),xic,aic); % 96 step-ahead predictionwithout any input
legend('predicted values')
As you can see from plot the error is very high and it seems shift in period, and the closedloopperformance equals to 0.0615, which is high I guess. Any help will be appreciated. Thanks,
Fred on 31 Aug 2018
It is 15 minute interval time-series, and I stored it in cell because the example datasets are all stored in cell in MATLAB.

Sign in to comment.

Answers (1)

Shashank Bhatia
Shashank Bhatia on 11 Sep 2018
For standarized data (mean = 0 & Var = 1), Steps are as follows:
1. Calculate number of hidden layers and number of feedback delays. --> Via autocorrelation method
2. Selection of training function --> depending upon data complexity, length, and time available
3. Divide data between training, validation and Testing --> use divideblock
4. Training the open loop
5. Defining the closed loop network --> choosing appropriate function for closed loop
6. training the closed loop
7. after confirming accuracy (check mse and perform) of the models, use closed loop trained network for prediction.
  1 Comment
Lucas Ferreira-Correia
Lucas Ferreira-Correia on 22 Jul 2019
Hi when you said
"5. Defining the closed loop network --> choosing appropriate function for closed loop"
do you mean specify a different training solver or what do you mean?
In addition to that does
"6. training the closed loop"
mean that the closed loop should be trained again the exact same way as the open loop, so with the same data?
I realise this is an old thread but your help would be greatly appreaciated!

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!