Narxnet: time shift of predicted value with respect to real target value

6 visualizaciones (últimos 30 días)
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

Respuesta aceptada

Greg Heath
Greg Heath el 4 de En. de 2016
Editada: Greg Heath el 6 de En. de 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

Más respuestas (1)

Ilaria Di Fresco
Ilaria Di Fresco el 12 de En. de 2016
Hi Greg,
Thanks for your answer. Yes, I solved the problem of the time shifting.
I explicitly decomposed the X and T time series because in this way I can specify the number of step ahead that I want to predict: N.
Actually, this is now how I define the two series:
inputseries=X(1:end-2*N);
targetseries=T(N+1:end-N);
inputseriesfuturestepahead=X(end-delay-2*N+1:end-N);
targetseriesfuturestepahead=T(end-delay-N+1:end);
In this way I can take in to account the time shifting generated by the function preparets and I can always predict future data using just past input (indeed, I've read several code that use future input in order to predict future target, but how can I know the future input?).
Do you think that this is correct?
Do you have other idea to obtain the same result?
Thanks
Ilaria

Categorías

Más información sobre Sequence and Numeric Feature Data Workflows en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by