How can I use neural network for multi step ahead prediction

24 views (last 30 days)
This is my script file of my neural network toolbox. I am going to predict for multi step ahead, but in this script only gave me 0ne step ahead (ys) prediction. How can I modify this script to multi-step ahead prediction?
clc; clear; close all;
% Solve an Autoregression Time-Series Problem with a NAR Neural Network % VarName1 - feedback time series. % The VarName1 is my original time series consists a matrix (272*1)
targetSeries = tonndata(VarName1,false,false);
% Create a Nonlinear Autoregressive Network feedbackDelays = 1:2; hiddenLayerSize = 10; net = narnet(feedbackDelays,hiddenLayerSize);
% Choose Feedback Pre/Post-Processing Functions net.inputs{1}.processFcns = {'removeconstantrows','mapminmax'};
% Prepare the Data for Training and Simulation [inputs,inputStates,layerStates,targets] = preparets(net,{},{},targetSeries);
% Setup Division of Data for Training, Validation, Testing 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;
% Choose a Training Function net.trainFcn = 'trainlm'; % Levenberg-Marquardt
% Choose a Performance Function net.performFcn = 'mse'; % Mean squared error
% Choose Plot Functions net.plotFcns = {'plotperform','plottrainstate','plotresponse', ... 'ploterrcorr', 'plotinerrcorr'};
% Train the Network [net,tr] = train(net,inputs,targets,inputStates,layerStates);
% Test the Network outputs = net(inputs,inputStates,layerStates); errors = gsubtract(targets,outputs); performance = perform(net,targets,outputs);
% Recalculate Training, Validation and Test Performance trainTargets = gmultiply(targets,tr.trainMask); valTargets = gmultiply(targets,tr.valMask); testTargets = gmultiply(targets,tr.testMask); trainPerformance = perform(net,trainTargets,outputs); valPerformance = perform(net,valTargets,outputs); testPerformance = perform(net,testTargets,outputs);
% Closed Loop Network netc = closeloop(net); [xc,xic,aic,tc] = preparets(netc,{},{},targetSeries); yc = netc(xc,xic,aic); perfc = perform(net,tc,yc);
% Early Prediction Network nets = removedelay(net); [xs,xis,ais,ts] = preparets(nets,{},{},targetSeries); ys = nets(xs,xis,ais); closedLoopPerformance = perform(net,tc,yc);
Thanks and Regards, Tiurmai

Accepted Answer

Greg Heath
Greg Heath on 1 Jul 2013
Increase the number of feedback delays.
Hope this helps
Thank you for formally accepting my answer
Greg
  4 Comments
Tiurmai Hutajulu
Tiurmai Hutajulu on 5 Jul 2013
how many step of prediction can be produced by increasing the number feedback delay??
Thank you Tiurmai
Greg Heath
Greg Heath on 8 Jul 2013
FD = a sequence of increasing, not necessarily consecutive, positive integers.
If max(FD) = m, you can predict m timesteps ahead.
If the number of feedback delays is less than m (e.g., 1:2:m) you can fill in the missing delays to get FD = 1:m with ~double the number of delays However, that will not increase the prediction time because max(FD) remains constant.
However, the increased number of delays may substantially improve performance.
Hope this helps.
Greg

Sign in to comment.

More Answers (0)

Categories

Find more on Deep Learning Toolbox in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!