Time-series prediction using another time series
Show older comments
I am working on a dynamic model for which I want to predict its time-series response when subjected to input time-series.
Let's say X1(t) is input vector and Y1(t) is corresponding output vector. After training, I want my model to predict the response of a completely new time-series input, say Y2(t) as response when it is given X2(t) as input vector. I have tried NARXnet. However, after making it close loop once training is done, it still requires a target data, which in my case is not available and that is what I want my model to predict using only input data i.e. X2(t).
Am i using the correct network i.e. NARXnet or not? If not, what else I should look for?
Code is shown below:
X = tonndata(X1,false,false); %input time-series
T = tonndata(Y1,false,false); %output time-series
trainFcn = 'trainbr'; % Bayesian Regularization backpropagation.
% Create a Nonlinear Autoregressive Network with External Input
inputDelays = 1:2;
feedbackDelays = 1:2;
hiddenLayerSize = 10;
net = narxnet(inputDelays,feedbackDelays,hiddenLayerSize,'open',trainFcn);
% Prepare the Data for Training and Simulation
[x,xi,ai,t] = preparets(net,X,{},T);
% Setup Division of Data for Training, Validation, Testing
net.divideFcn = 'dividerand'; % Divide data randomly
net.divideMode = 'time'; % Divide up every sample
net.divideParam.trainRatio = 70/100;
net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 15/100;
% Choose a Performance Function
net.performFcn = 'mse'; % Mean Squared Error
% 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)
% Closed Loop Network
netc = closeloop(net);
netc.name = [net.name ' - Closed Loop'];
view(netc)
X_new = tonndata(X2,false,false); %new time series for which i want to get output without having Y2
T_new = tonndata(Y2,false,false); %i don't have this response time-series. I want to predict this using X2 i.e. X_new
[xc,xic,aic,tc] = preparets(netc,X_new,{},T_new);
yc = netc(xc,xic,aic);
closedLoopPerformance = perform(netc,tc,yc)
Answers (1)
Srivardhan Gadila
on 11 Mar 2020
0 votes
Categories
Find more on Pattern Recognition 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!