NARXNET OUTPUT TIMING INTERPRETATION

1 view (last 30 days)
Mario Viola
Mario Viola on 1 Mar 2021
Hi all!
I'm having a really hard time understanding the timing in the narxnet environment. Very briefly, i'd like to predict next day return direction based on a series of inputs and targets, delayed.
FD = 1:9; %autocorr(r) significant up to lag 9
ID = 1:20; %crosscorr significant up to lag 20 (even more)
net = narxnet(ID,FD,hiddenLayerSize,'open',trainFcn);
I am using divideblock division, tansig transfer function, and my output prediction is in terms of 1 & 0 (up/down trend, respectively).
[Xs,Xi,Ai,Ts] = preparets(net,Xin,{},yin);
[net tr] = train(net,Xs,Ts,Xi,Ai);
[P Xf Af] = net(Xs,Xi,Ai);
Xin is a 2490x9 matrix (9 predictors), while yin is a 1x2490 vector of 1 & 0 (up/down trend for the day). Now, each row of both X and Y, represents contemporaneus observations, meaning X(t) and y(t), as i defined them. When outputting P, that has the same legnth as Ts ( that is indeed yin minus the inital states/delays), each element represents the prediction at time t as well, rigth ? I mean that if Ts(1) is the target at time t, then P(1) would refer to time t as well, while Ts(2) = P(2) = time 't+1' etc.
[netc,Xic,Aic] = closeloop(net,Xf,Af);
Xout = tonndata(Xout,false,false);
y_c = netc(Xout,Xic,Aic);
Then i move to the closeloop environment to make predictions, based on unseen data Xout. Now, my question is:
The first element of y_c (i.e. y_c(1)), is based on the initial conditions of Xic AND the first value of Xout ? What i mean is that, if we say that y_c(1) = y(t), then it has been predicted based on Xic (with the previous notation, could be defined as [X(t-1) ...... X(t-20]) AND also on Xout(1) (i.e. X(t), with the same notation) ?
I am really in trouble with this, and it is a doubt i am not able to answer myself even after reading lots of posts and answers. What i'd like to understand in general is how to interpret the predictions i get from the closed loop form, as i need to simulate a trading strategy. Each y_c(i) has to be multiplied for the retun in position (i+1), if the prediction is at time 't+1', as i think it is defined. I also tried to add the 'removedelay' command, which is even more confusing when dealing with the 0 delay.
Hope that someone could clarify this, i really run out of material about this.

Answers (0)

Community Treasure Hunt

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

Start Hunting!