Narxnet: time shift of predicted value with respect to real target value
7 views (last 30 days)
Show older comments
Ilaria Di Fresco
on 23 Oct 2015
Answered: Ilaria Di Fresco
on 12 Jan 2016
I am writing NARX for forecasting the wind speed one day ahead, based on the historical data of wind speed and wind direction. One of my problem is that when I plot the results, the output are time shifted to the left of one time step.
WHY DOES THIS HAPPEN?
HOW CAN I SOLVE IT?
X=con2seq(V1');
T=con2seq(V2');
N=24; %number of steps ahead
%the number of Hidden layer and delay ARE NOT OPTIMIZED YET! I will use the
%function nncorr as suggested in many posts
delay=2;
neurons=5;
inputseries=X(1:end-N);
targetseries=T(1:end-N);
inputseriesval=X(end-N+1:end);
targetseriesval=T(end-N+1:end);
%openloop
net=narxnet(1:delay,1:delay,neurons);
net.divideFcn = 'divideblock';
[Xs,Xi,Ai,Ts]=preparets(net,inputseries,{},targetseries);
net=train(net,Xs,Ts,Xi,Ai);
[Y,Xf,Af]=net(Xs,Xi,Ai);
perf=perform(net,Ts,Y);
%closeloop
netc=closeloop(net,Xf,Af);
[Xc,Xic,Aic,Tc]=preparets(netc,inputseries,{},targetseries);
netc=train(netc,Xc,Tc,Xic,Aic);%I train the closeloop to get a more accurate closeloop
Ypred=netc(inputseriesval,Xic,Aic);
multistepperf=perform(netc,Ypred,targetseriesval);
view(netc) figure;
%operation required because I first normalized the input and target data.
%In this way the graph represent a real quantity (wind speed)
[A]=unnormalize(Ypred,m);
[C]=unnormalize(Y,m);
[B]=unnormalize(T,m);
plot([C,A]);
hold on;
plot(B,'red');
The performance still need to be improved for 24 HOURS AHEAD forecast. As you can see the prediction in blues has a lag compared to the target values (in red).
Thanks for your help.
Ilaria
0 Comments
Accepted Answer
Greg Heath
on 4 Jan 2016
Edited: Greg Heath
on 6 Jan 2016
1. By default, TRAIN automatically divides the data. As long as you use divideblock, I see no reason for you to explicitly decompose X and T.
2. The red curve lags the blue curve. Not vice versa.
3. The blue curve should be shifted to the right because the initial delays were not taken into consideration.
Hope this helps.
Thank you for formally accepting my answer
Greg
0 Comments
More Answers (1)
See Also
Categories
Find more on Sequence and Numeric Feature Data Workflows 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!