MATLAB: Hello everyone, the input data set is 8 by 3392 and output data set is 1 by 3392, this data was collected hourly, the objective is to foreast next five hours or more using NARX,please help out

Deep Learning Toolboxmachine learningnarxneural network

% P_N_Hourly - input time series.
% Q_N_Hourly - feedback time series.
X = tonndata(P_N_Hourly,true,false); T = tonndata(Q_N_Hourly,true,false);
% Choose a Training Function
trainFcn = 'trainlm'; % Levenberg-Marquardt backpropagation.
% Create a Nonlinear Autoregressive Network with External Input inputDelays = 1:2; feedbackDelays = 1:2; hiddenLayerSize = 10; net = narxnet(inputDelays,feedbackDelays,hiddenLayerSize,'open',trainFcn);
[x,xi,ai,t] = preparets(net,X,{},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 view(net)
% Plots % Uncomment these lines to enable various plots. %figure, plotperform(tr) %figure, plottrainstate(tr) %figure, ploterrhist(e) %figure, plotregression(t,y) %figure, plotresponse(t,y) %figure, ploterrcorr(e) %figure, plotinerrcorr(x,e)
% Closed Loop Network % Use this network to do multi-step prediction. % The function CLOSELOOP replaces the feedback input with a direct % connection from the outout layer. 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)
% Step-Ahead Prediction Network % For some applications it helps to get the prediction a timestep early. % The original network returns predicted y(t+1) at the same time it is % given y(t+1). For some applications such as decision making, it would % help to have predicted y(t+1) once y(t) is available, but before the % actual y(t+1) occurs. The network can be made to return its output a % timestep early by removing one delay so that its minimal tap delay is now % 0 instead of 1. The new network returns the same outputs as the original % network, but outputs are shifted left one timestep. 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)
% forecast 5 hour ahead PastData = T; K = 5; netf = openloop(net); [xf,xif,aif,~] = preparets(netf,X,{},T); sys = netf(xf,xif,aif); [yf,sysf,xf,xif,aif,tf] = forecast(sys,PastData,K);

Best Answer

Typically, you will have to make several designs before you finish.
Therefore, it makes more sense to start with the simplest algorithm and then, one-by-one, determine what improvements should be made.
Start with the code used in
help narxnet
doc narxnet
While learning, use additional MATLAB example data obtained from the commands
help nndata
doc nndata
In addition, I have posted zillions of examples in both the NEWSREADER and ANSWERS. For example, search using (Of course there will be overlap)
HITS
NEWSREADER ANSWERS
greg narx 57 264
greg narx recommended 11 30
and
greg narxnet 83 320
greg narxnet recommended 17 45
Hope this helps
Thank you for formally accepting my answer
Greg