hi
i want to use ann for forecasting water table
i have two set of data. water table from past and temperature.
it means two matrix with 12 column and 15 row
12 column means 12 month
and each row are separated data from a year(15 year).
it mean i have two data for month and year
i devided my data into 2 matrix
first 11 year for input and 4 year for output
i want to use nntool to forecast and predict water table for future years with under consideration of temperature. now my questions:
  1. some of my data don't have value and matlab give them 0 in my table. is this affect the network? and if it is what should i do?
  2. do i need to normalize my data before using nntool and how?
  3. when i start nnstart, do i need to use time series?
  4. how i consider the effect of temperature?
sorry for my long question. I am new in matlab and have a lot of question. thanks a lot.

 Réponse acceptée

Greg Heath
Greg Heath le 7 Sep 2016

1 vote

I would unfold your data into a single 2 dimensional input time series matrix of size
[ 2 180 ] = size(series)
where the inputs are waterlevel and temperature.
The target is just the future waterlevel.
To estimate how far into the future you can predict, obtain the autocorrelation function of waterlevel and crosscorrelation function of waterlevel and temperature.
From the correlation functions you can determine the significant lags of the local correlation peaks.
Then use a subset of the significant lags in a narxnet.
Hope this helps.
Thank you for formally accepting my answer
Greg

4 commentaires

majid a
majid a le 14 Sep 2016
thanks for response
I remove some parameter in my question to simplify it.
i have 3 matrix. waterlevel, rain and temperature.
how should i unfold the matrix ? the column and rows are different. one of them is the year and one of them is month.
it get me a string of numbers.
how can i use crosscorrelation for 3 Characteristic?
Greg Heath
Greg Heath le 15 Sep 2016
Modifié(e) : Greg Heath le 15 Sep 2016
Assume you have 3 15x12 matrices of temperature, rainlevel, and waterlevel which are unfolded into 3 timeseries of N = 180 days and combined into one 3x180 data matrix.
For a prediction of d days ahead
[ I N-d ] = size(input) = [ 3 N-d ]
[ O N-d ] = size(target) = [ 3 N-d ]
You would then have 3 autocorrelation functions and 9 (corrected from 6) cross-correlation functions to use for estimates of what d should be.
Of course you can reduce the number of outputs if you wish.
Hope this helps
Greg
majid a
majid a le 15 Sep 2016
thanks again for helping.
i divide my matrices and now i have 4 matrix.
1 for rain [1*180]
1 for temperature [1*180]
1 for waterlevel [1*180]
and a combine of those 3 [3*180]
when i use code :
xcorr(rain)
%for finding auto correlation of rain
its get me a 1*355 matrix!
when i set the lag to 1 it gets me this
xcorr(rain,1)
ans =
1.0e+07 *
2.0621 2.1315 2.0621
i searched in the internet and find a function that calculate acf but it needed lag p.
how can i know lag p?
and when i run it with lag 1 this happen:
acf(rain,1)
ans =
0.8492
i am really confused..
sorry to bother you again.
Greg Heath
Greg Heath le 15 Sep 2016
Modifié(e) : Greg Heath le 15 Sep 2016
Search in both the NEWSGROUP and ANSWERS using
greg nncorr
greg nncorr narxnet
Hope this helps.
Greg

Connectez-vous pour commenter.

Plus de réponses (1)

majid a
majid a le 8 Fév 2017

0 votes

%%Change Data
DD = [];
for ii=1:13
D = Data(1:12,ii);
DD = [DD ; D]
end
for ii=13:(numel(DD)-5)
D_0(ii-12,1) = DD(ii-0);
D_1(ii-12,1) = DD(ii-1);
D_2(ii-12,1) = DD(ii-2);
D_3(ii-12,1) = DD(ii-3);
D_6(ii-12,1) = DD(ii-6);
D_12(ii-12,1) = DD(ii-12);
D_plus_3(ii-12,1)=DD(ii+3);
D_plus_1(ii-12,1)=DD(ii+1);
end
X = [D_0 D_1 D_2 D_3 D_6 D_12];
Y = D_plus_1;
DataNum = size(X,1);
InputNum = size(X,2);
OutputNum = size(Y,2);
%%Normalization
MinX = min(X);
MaxX = max(X);
MinY = min(Y);
MaxY = max(Y);
XN=X;
YN=Y;
for ii=1:InputNum
XN(:,ii)=Normalize_Fcn(X(:,ii),MinX(ii),MaxX(ii));
end
for ii=1:OutputNum
YN(:,ii) = Normalize_Fcn(Y(:,ii),MinY(ii),MaxY(ii));
end
%%Test And Train Data
TrPercent=80;
TrNum = round(DataNum * TrPercent/100);
TsNum = DataNum - TrNum;
R=randperm(DataNum);
trIndex = R(1 : TrNum);
tsIndex = R(1+TrNum : end);
Xtr = XN(trIndex,:);
Ytr = YN(trIndex,:);
Xts = XN(tsIndex,:);
Yts = YN(tsIndex,:);
%%Network Structure
pr = [-1 1]
PR = repmat(pr,InputNum,1);
Network = newff(PR,[10 5 OutputNum],{'tansig' 'tansig' 'tansig'});
%%Training
[Network,NN] = train(Network,Xtr',Ytr');
view(Network);
%%Assesment
YtrNet = sim(Network,Xtr')';
YtsNet = sim(Network,Xts')';
MSEtr = mse(YtrNet - Ytr)
MSEts = mse(YtsNet - Yts)
I couldn't find out how to consider cross correlation in my network. and how i can forecast in the future??? thanks

Community Treasure Hunt

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

Start Hunting!

Translated by