# Artificial Neural Network (ANN) Regression Fitting (fitnet) difference in R2 (r-squared) values calculated from NMSE (Normalized Mean Square Error) and best performance data values from the training record (tr)

29 views (last 30 days)
fred ssemwogerere on 7 Sep 2019
Hello Community,first and foremost am grateful for all your posts and answers. They have proved to be invaluable and of great help in my work. This question is particularly directed to Professor Greg Heath, but still i would welcome any contribution from the community. I picked some knowledge in designing a regression neural network from some of the codes that were posted. However, there is one isssue of contention regarding the coefficient of determination, R2. The values of R2 calculated using R2=1-NMSE and R2=1-tr.best_perf/MSE00 seem to be different. Why so? I would expect the 2 to be different. Also, I would very much appreciate if you share more knowledge on obtaing the values of the coefficient of correlation, R, from the validation and testing set, that matches with the values from the 'nntraintool' for plotting 'Regression". My calculated data values of "R" do not match with the plots. Am using the 'for' loop given in one of Professor Greg's answers for designing the networks with a defined random weight initialization value (10).
% Part of the code is shown below
MSE00=mean(var(t,1));
MSE0=SSE/Ntrneq;
R2btrn=1-tr.best_perf/MSE00;
NMSEb=1-MSE0/MSE00
R2b=1-NMSEb;
% Output for 10 randow weight initializations and for one hidden layer and hidden nodes: 1 and 6
% This is data reproduced using 'tansig' in both input and output layers
R2btrn
0.1735 0.5974
0.5313 0.6022
0.5290 0.5765
0.5392 0.5943
0.5363 0.6012
0.5155 0.6038
0.5434 0.5812
0.5524 0.5905
0.5159 0.5899
0.5316 0.6030
R2b
0.1640 0.5965
0.5355 0.5922
0.5350 0.5804
0.5353 0.5899
0.5357 0.6008
0.5348 0.6002
0.5270 0.5713
0.5341 0.5925
0.5267 0.5875
0.5358 0.5999
NMSEb
0.8360 0.4035
0.4645 0.4078
0.4650 0.4196
0.4647 0.4101
0.4643 0.3992
0.4652 0.3998
0.4730 0.4287
0.4659 0.4075
0.4733 0.4125
0.4642 0.4001
% I will appreciate all your help in understanding this anomally. Thanks.
% Regards, Fred

R2017a

### Community Treasure Hunt

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

Start Hunting!