MATLAB: 1. what is the minimum number of the input(Data) that u can use to train Neural Network for Multi Step Ahead Prediction?,2. how can I feed the following data to the code?,(the data are{54 60 69 73 79 80) I want to predict multi step ahead

prediction using neural network

%load data
S = load('magdata');
X = con2seq(S.u);
T = con2seq(S.y);
% DESIGN NETWORK
[x,t] = simplenarx_dataset;
net = narxnet;
[X,Xi,Ai,T] = preparets(net,x,{},t);
net = train(net,X,T,Xi,Ai);
view(net)
% SIMULATE NETWORK FOR ORIGINAL SERIES
[Y,Xf,Af] = sim(net,X,Xi,Ai);
% CONTINUE SIMULATION FROM FINAL STATES XF & AF WITH ADDITIONAL
% INPUT DATA USING CLOSED LOOP NETWORK.
% Closed Loop Network
netc = closeloop(net);
%netc = closeloop(net,Xf,Af);
%view(netc)
% 10 More Steps for the first (now only) input
X2 = num2cell(rand(1,10));
% Initial input states for closed loop continuation will be the
% first input's final states.
Xi2 = Xf(1,:);
% Initial 2nd layer states for closed loop contination will be the
% processed second input's final states. Initial 1st layer states
% will be zeros, as they have no delays associated with them.
Ai2 = cell2mat(Xf(2,:));
for i=1:length(net.inputs{1}.processFcns)
fcn = net.inputs{i}.processFcns{i};
settings = net.inputs{i}.processSettings{i};
Ai2 = feval(fcn,'apply',Ai2,settings);
end
Ai2 = mat2cell([zeros(10,2); Ai2],[10 1],ones(1,2));
% Closed loop simulation on X2 continues from open loop state after X.
Y2 = sim(netc,X2,Xi2,Ai2);
plot(1:length(t),cell2mat(t))
hold on
plot(1:length(x),cell2mat(x),'r')
plot(length(t):length(t)+length(Y2)-1,cell2mat(Y2),'g')
legend('Input data - target series','One-step ahead prediction','Multi-step prediction beyond')

Best Answer

You do not want the number of unknown parameters, Np, to exceed the number of training equations, Ntrneq.
In the default mode you typically have
1. N O-dimensional "O"utput target vectors
2. N I-dimensional "I"nput vectors
3. Ntrn = N-2*round(0.15*N) training vector pairs
4. Ntrneq = Ntrn*O training equations
5. NID = di input delays in the input delay vector ID = 1:di
6. NFD = df output feedback delays in the feedback delay vector
FD = 1:df
7. Input, hidden and Output layer node topology I-H-O
8. Number of unknown weights
Nw = (NID*I+NFD*O+1)*H+(H+1)*O
9. Given all training parameters except weights, it is desired
to have at least as many training equations than unknown
weights. Therefore,
Ntrn >= Nw/O
10. However, Ntrn >> Nw/O tends to yield more stable solutions.
11. In most cases Ntrn is known and the inequality is
rearraranged to yield an upper bound limit for the number of
hidden nodes
H <= Hub = (Ntrneq-O)/(NID*I+NFD+O+1)
12. Similarly, if an acceptable solution with H << Hub is
possible, it will be more stable.
13. I'm afraid you cannot do much with that few number of data points
(typically true for most statistical analyses).
Hope this helps.
Greg