How to do Single step ahead prediction of multivariate time series using NARXNET.

2 views (last 30 days)
I want to do one step ahead prediction of multivariate time series using NARXNET. Can anyone share a working example of training NARX network with multiple input vectors? I mainly focus on to predict only 1 point ahead.
The defining equation for the NARX model is
y(t)=f(y(t-1),y(t-2),y(t-3) ,x1(t-1),x1(t-2),x1(t-3),x2(t-1),x2(t-2),x2(t-3))
where the next value of the dependent output y(t) is regressed on previous values of the output and previous values of an independent (exogenous) input . I have two exogenous inputs.
Here are the vectors which I have 10 values:
Y = [3.4, 4.3, 0 , 2.6, 1.2, 0.32 ,1.4 ,4.6 ,5.2, 2.2]; X1 = [2, 2, 0 , 3, 4, 1 ,7 ,1 ,3, 2]; X2 = [1, 0, 0 , 1, 2, 1 ,1 ,2 ,1, 1];
I want to predict the future value of Y at t=10, in other words I want to predict Y(10) value by using the Y(1:9) and two exogenous inputs X1(1:9), X2(1:9) values.
I have 2 questions
1-) What is the meaning of the 6 predicted values "predict = [1.9427] [1.1447] [-0.3674] [0.9813] [5.8055] [-1.8244]" ?
I focus on to predict only 1 point ahead of the Y value, "predict{1} - [1.9427]" is it the correct value of the prediction of the 1 point ahead of the Y value.
How can I print the only 1 point ahead of the Y value?
2-) How can I include the second exogenous input X2 to the model ? Using "net = newnarxsp(...);" command is the correct way of training NARX network with multiple input vectors?
Can anyone share a working example of "net = newnarxsp(...);" training NARX network with multiple input vectors?
thanks in advance.
Here is the code:
close all, clear all, clc, format compact
Y = [3.4, 4.3, 0 , 2.6, 1.2, 0.32 ,1.4 ,4.6 ,5.2, 2.2];
Y = Y(1:9);
X1 = [2, 2, 0 , 3, 4, 1 ,7 ,1 ,3, 2];
X1 = X1(1:9);
X2 = [1, 0, 0 , 1, 2, 1 ,1 ,2 ,1, 1];
X2 = X2(1:9);
Y = con2seq(Y);
X1 = con2seq(X1);
X2 = con2seq(X2);
delay = 3;
neuronsHiddenLayer = 10;
% Network Creation
net = narxnet(1:delay,1:delay,neuronsHiddenLayer);
[Xs,Xi,Ai,Ts] = preparets(net,X1,{},Y);
net = train(net,Xs,Ts,Xi,Ai);
predict = net(Xs,Xi,Ai);
predict;
%predict =
% [1.9427] [1.1447] [-0.3674] [0.9813] [5.8055] [-1.8244]
fprintf('%s',predict{1});
% [1.9427]

Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!