MATLAB: Predicting time-series Y (t+1) with Neural Networks

neural networktime series

I have a data set that I split into:
  • training: predictors X_TR (1028records in 14 variables) and Y_TR (1028records single variable),
  • application: X_APP (115 x 14), Y_APP (115×1),
where each record is a time step t.
My goal is to construct a NN model that predicts Y(t+1) using whatever historical information up to t, that is Y(T+1) = f(X(t),X(t-1),…,Y(0),X(t),X(t-1),…,Y(0)). Note that it is reasonable to consider iformation no older than 10 time steps. According to mathworks.com/help/nnet/gs/neural-network-time-series-prediction-and-modeling.html, I have trained a NN using X_T and Y_T.
% Cell arrays inputs for NN
X = tonndata(X_TR,false,false);
T = tonndata(Y_TR,false,false); %output volumes
% training function
trainFcn = 'trainlm'; % Levenberg-Marquardt
% Create NARX
% network parameters
lags = 10;
inputDelays = 1:lags;
feedbackDelays = 1:lags;
hiddenLayerSize = 40;
% construct NARX net
net = narxnet(inputDelays,feedbackDelays,hiddenLayerSize,'open',trainFcn);
%prepare time series
[x,xi,ai,t] = preparets(net,X,{},T);
% Training, Validation, Testing
net.divideParam.trainRatio = 60/100;
net.divideParam.valRatio = 20/100;
net.divideParam.testRatio = 20/100;
% Train the Network
[net,tr] = train(net,x,t,xi,ai);
I don't know how to apply the trained model. Let say that the training was successful and I would like to apply the model on the other part of the data X_APP and Y_APP such that it predicts Y_APP(t+1). How could I do it?
Thank you.

Best Answer

You have no proof that the Open Loop (OL) training is successful. Often it is not because of insufficient values for
1. input lags
2. feedback lags
3. number of hidden nodes
4. choice of initial weights
Even if you calculate the OL Normalized Mean Square Error
[ net tr y e ] = train(net,x,t,xi,ai);
NMSE = mse(e)/mean(var(t,1))
and it is less than 0.005, there is no guarantee that the error will remain sufficiently low when you close the loop to obtain the CL configuration for future predictions.
I have written many posts in both NEWSGROUP and ANSWERS that explain the complete process.
Unfortunately, my computer crashed and I have lost my notes on exactly which posts are sufficient. In addition I have not had time to figure out how to install MATLAB again.
At this point all I can suggest is to search the NEWSGROUP using
greg narxnet openloop
and
greg narxnet closeloop
Sorry,
Greg