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
Best Answer