Neural network toolbox to forecast wind speed

19 views (last 30 days)
Carina
Carina on 21 Jul 2017
Commented: georg enyew on 26 Nov 2020
Hello. First of all I would like to say I've read the Matlab tutorials regarding NAR NARX, closeloop etc and most of the answers provided by Greg.I ran the examples provide but I need some help to understand some of the concepts, since I'm stuck in the * delay* concept.
My problem is this: I want to forecast wind speeds, 2 or 3 days ahead using a past time-series obtained from a reanalysis dataset for example. I've managed to run small pieces of code, some of them obtained here in the MATLAB answers, adapted to my problem. I want to run two test cases: one using only past values of wind, and a second one using past measurements of temperatures, pressure and relative humidity as input, to forecast wind.
This is what I accomplished so far (I repeat I might have used some code posted here, I'll change it in the future but it's easier to explain my doubts). Can you please take a look at the code and answer me some questions? Any help would be appreciated I just want to understand the basic concepts so that I change my code to more complex problems.
Imagine a 9 columns file with two years of weather data. (I can provide a file if it helps) I load the file
hr=data(:,6);
pres=data(:,5);
vento_dir=data(:,8);
temp=data(:,7);
wind=data(:,9);
weather_data= ([hr,pres,wind_dir,temp]);
N = 30;
weather_data=tonndata(weather_data,false,false);
wind=tonndata(wind,false,false);
inputSeries = weather_data(1:end-N);
targetSeries = wind(1:end-N);
%This is the new data I will obtain from another source, but right now, to test, I'll use the last 30 timesteps (data is hourly)
inputSeriesVal = weather_data(end-N+1:end);
targetSeriesVal = cell(1,30);
targetSeriesVal(:) = {NaN}; %NaN because I don't have this yet
delay = 2;
neuronsHiddenLayer = 8;
% 3. Network Creation
net = narxnet(1:delay,1:delay,neuronsHiddenLayer);
%%4. Training the network
[Xs,Xi,Ai,Ts] = preparets(net,inputSeries,{},targetSeries);
net = train(net,Xs,Ts,Xi,Ai);
*
Y = net(Xs,Xi,Ai);*
%%%%%%%%%%%%%%
%%5. Multi-step ahead prediction (do I have to use this bedore step 6?? why?? can't I forecast from here??)
[Xs1,Xio,Aio] = preparets(net,inputSeries(1:end-delay),{},targetSeries(1:end-delay));
[Y1,Xfo,Afo] = net(Xs1,Xio,Aio);
%%6. close the loop)
[netc,Xic,Aic] = closeloop(net,Xfo,Afo);
[yPred,Xfc,Afc] = netc(inputSeriesVal,Xic,Aic);
multiStepPerformance = perform(net,yPred,targetSeriesVal);
figure;
plot(nan(1,length(targetSeries)),cell2mat(targetSeriesVal)]')
legend('Original Targets','Network Predictions','Expected Outputs')
ok, I have some questions.
1. First of all, I have some trouble understanding what delays are. if I run this code my 'Network Predictions' seem one timestep delayed from my 'Expected Outputs'. Does it mean that if I want to plot a graphic or calculate a correlation coefficient I need to do something like: correl(Network Predictions(2,:);Expected Outputs(1:end-1) ?? or am I completely mistaken??
2. If I change the delays to 7 instead of 2, does it mean my Network Predictions will now be 7 steps lagged?, I mean the first Network Prediction will correspond to the 7th Expected Output?? I can't understand the lag concept, even though I've read the tutorial...and I need to know whether I'm comparing the forecasts with the actual data I want to forecast.
3. Now, the step 5, multi step prediction, do I need to run that peace of code instead of doing the closeloop right after Y = net(Xs,Xi,Ai); (In bold)
4. In some cases, I don't have any new inputs to feed the network, because I want to forecast winds, let's say for tomorrow and the next two days, so I don't have any inputs yet, except if I use the results from a global model. Can I close the loop and forecast 30 steps ahead without using any new input? how??? (probably using NAR right?)
I've read in other topics that some people use something like this as delays: valsPerHour = 4; % 60 / 15 mins inputDelays = 0; feedbackDelays = (6 * valsPerHour) : valsPerHour : (29 * valsPerHour); hiddenLayerSize = 100; net = narxnet(inputDelays, feedbackDelays, hiddenLayerSize);
4. Had I used this piece of code, do I still need to close the loop or will this give my forecasts 29 steps ahead?
Any piece of code would be useful since I'm having troubles understanding the concepts just by reading about them. I know these questions might be confusing or even basic to some of you but I've been searching answers for weeks...and the more I read the more confused I get.
Thank you so much in advance, any help will be so much appreciated.
Carina
  3 Comments
Greg Heath
Greg Heath on 28 Jul 2017
Edited: Greg Heath on 28 Jul 2017
Are you still working on a set from the MATLAB example database that I recommended?
If not, just start with
[ x t ] = simplenarx_dataset;
and let me know if you have any problems/questions.
Greg
georg enyew
georg enyew on 26 Nov 2020
this quetion is the same to me too. but my prediction is for rain fall.
pls help us

Sign in to comment.

Answers (0)

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!