NARX how do feedback delays work?
Show older comments
I need to model y(t) using x(t-12) and y(t-12) only, hence have 'inputDelays = 12' but I cannot figure out whether feedbackDelays should be '12' or '1:12'. If the feedback is using the real target values y(t) I think it should be 'feedbackDelays = 12', but if the feedback is using the model output yhat(t) should I use 'feedbackDelays = 1:12' to produce a better fitting model? Would this adhere to modelling y(t) using x(t-12) and y(t-12) only?
My code is:
target= load('target_data.txt');
input = load('input_data.txt');
X = tonndata(input,false,false);
T = tonndata(target,false,false);
trainFcn = 'trainlm'; % Levenberg-Marquardt backpropagation.
% Create a Nonlinear Autoregressive Network with External Input
inputDelays = 12;
feedbackDelays = 1:12;
hiddenLayerSize = 10;
net = narxnet(inputDelays,feedbackDelays,hiddenLayerSize,'open',trainFcn);
[x,xi,ai,t] = preparets(net,X,{},T);
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)
netc = closeloop(net);
netc.name = [net.name ' - Closed Loop'];
view(netc)
[xc,xic,aic,tc] = preparets(netc,X,{},T);
yc = netc(xc,xic,aic);
closedLoopPerformance = perform(net,tc,yc)
nets = removedelay(net);
nets.name = [net.name ' - Predict One Step Ahead'];
view(nets)
[xs,xis,ais,ts] = preparets(nets,X,{},T);
ys = nets(xs,xis,ais);
stepAheadPerformance = perform(nets,ts,ys)
Thanks in advance, Alana
Answers (0)
Categories
Find more on Signal Modeling in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!