Narxnet Multistep forecast within the time series

Hi all,
I've been reading these forums for a while now, and they've been quite useful. Nevertheless, now I'm in front of a problem that I haven't been able to solve, unfortunately, and I cannot find the answer in these forums.
I'm currently working with a Narxnet to predict climatology. Previously, just by using narnet I had a code that allowed me to do a forecast anywhere within the time series (E.g. If my trained time series has 100 elements(t=100), I was able to see what would happen with the closed loop at t=20, 25, 30, ... Basically, to assess the forecast at any given point within my time series and not necessarily at the end (t>100)). Then I changed my ANN to Narxnet but I've encountered the problem that I cannot make a prediction using the closed loop if the delays of my Inputs and Targets are different. Let's say I want to use the previous 5 days to predict Sea Surface Temperature but just using the previous 2 days of Heat Flux information as Input.
Is it possible to make a multi step prediction using different delays for inputs and targets? Or do I always have to consider same size cell arrays for input and targets when using preparets?
Thank you all,
Cesar

 Accepted Answer

1. NARXNET and TIMEDELAYNET require:
All input delays to be increasing (not necessarily consecutive) and NONNEGATIVE. All inputs have the same delays.
2. NARXNET and NARNET require:
All feedback delays to be increasing (not necessarily consecutive) and POSITIVE. All outputs have the same delays.
Hope this helps.
Thank you for formally accepting my answer
Greg

5 Comments

Thank you for your answer. It solved one of my main doubts. If you don't mind I have another tiny question but I didn't want to open a new thread to ask you about this.
In a previous post Multi step ahead predictions using NARNET http://uk.mathworks.com/matlabcentral/newsreader/view_thread/342655
you mention that if we want to get predictions beyond the target, then we need to input an array of empty cells:
Prediction=cell(1,N)
with N, being the amounts of time steps we want to predict ahead. I can see that this example works when we have one dimension, nevertheless, I'm currently working with 100 EOFs, and therefore this won't be a single vector problem. Do you know what is the input for empty cells in this case? It seems that matlab is waiting for me to give it a cell array of 1,N where each element of the cell has a shape of 100x1.
Thank you for your time and help, it's highly appreciated
César
Isn't it obvious that the first dimension of the cell must be the first dimension of the orignal target?
Greg
Dear Greg,
I tried that option too, but then I receive:
??? Error using ==> network.sim at 121
Number of inputs does not match net.numInputs.true
I used the pollution dataset from the Matlab examples, and the following is a short version of the advanced script from the Neural Network Toolbox
load pollution_dataset
inputSeries = pollutionInputs;
targetSeries = pollutionTargets;
inputDelays = 1:2;
feedbackDelays = 1:2;
hiddenLayerSize = 10;
net = narxnet(inputDelays,feedbackDelays,hiddenLayerSize);
[inputs,inputStates,layerStates,targets] = preparets(net,inputSeries,{},targetSeries);
%Closed Loop
[net,tr] = train(net,inputs,targets,inputStates,layerStates);
netc = closeloop(net);
netc.name = [net.name ' - Closed Loop'];
[xc,xic,aic,tc] = preparets(netc,inputSeries,{},targetSeries);
yc = netc(xc,xic,aic);
%Multi step Prediction
xc2=cell(3,50) %3: Size of the targets; 50: prediction time steps ahead
yc = netc(xc2,xic,aic);
In the last line of code is where I receive the error, since I'm not completely sure what xc2 should be in order to make the multi step prediction ahead.
Thank you,
César
% Narxnet Multistep forecast within the time series % Asked by Cesar Quilodran Casas on 18 Apr 2016 at 17:40
close all, clear all, clc, load pollution_dataset
inputSeries = pollutionInputs; targetSeries = pollutionTargets;
inputDelays = 1:2; feedbackDelays = 1:2; hiddenLayerSize = 10;
net = narxnet(inputDelays,feedbackDelays,hiddenLayerSize);
[inputs,inputStates,layerStates,targets] = ...
preparets(net,inputSeries,{},targetSeries);
[net,tr] = train(net,inputs,targets,inputStates,layerStates);
GEH1 = 'Well, is it a good design? If not, you have to do it over ' ...
'before closing the loop!'
%Closed Loop
netc = closeloop(net);
netc.name = [net.name ' - Closed Loop'];
[xc,xic,aic,tc] = preparets(netc,inputSeries,{},targetSeries);
yc = netc(xc,xic,aic);
GEH2 = 'Should have [ yc xfc afc ] = ...
GEH3 = 'Well, is it a good design? If not, you have to do it over ' ...
'before trying to predict beyond tc(:,end)'
%Multi step Prediction
xc2=cell(3,50) %3: Size of the targets; 50: prediction time steps ahead
% yc = netc(xc2,xic,aic);
% In the last line of code is where I receive the error, since
% I'm not completely sure what xc2 should be in order to
% make the multi step prediction ahead.
GEH3 = 'WHOOPS! I told you target dimension instead of input dimension!'
GEH4 = 'Also need above final values to initialize the new prediction'
xc2 = cell(8,50);
xic2 = xfc;
aic2 = afc;
yc2 = netc(xc2,xic2,aic2);
GEH5 = 'Need numerous plots for a decent understanding of the problem'
Hope this helps.
Greg
Dear Prof. Heath Thank you for your fast response. I've tried your modified code but even if I put
xc2=cell(8,N)%8 is the dimension of inputs and N the forecasted time steps
I keep getting the same error. The only thing that works for me is
xc2=cell(0,N);
where N is the number of desired forecasted time steps. I got this idea from one of your previous posts. I suspect that this might not be the optimal answer since Matlab is expecting me to give any inputs. But in my case I want a complete "free running" model, not even giving inputs and completely targetless.
Cheers,
César

Sign in to comment.

More Answers (0)

Categories

Find more on ThingSpeak 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!