MATLAB: How to get the training output vector (a2) from newrb

newrbvariable from function

Greetings, I am using newrb in predicting the drilling rate of penetration (ROP). I am comparing the results with a multiple regression, thus I am using an F-test. I need both the training output and the simulated output for the comparison. In newrb function, the training output is a2. How can I get the value of a2 and use it in my code.

Best Answer

Apparently, there is a BUG in newrb. In previous versions
[ net tr ] = newrb(Xtrain,Ttrain);
would provide training history details in the structure tr in addition to providing the trained net.
Now, only the single output "net" is allowed and training history data is unavailable.
%CONSTANT MODEL TRAINING PERFORMANCE REFERENCE
[ O Ntrain ] = size(Ttrain)
Ytrain00 = repmat(mean(Ttrain,2),1,Ntrain));
MSEtrain00 = mse(Ttrain-Ytrain00)
%TRAINING:
MSEgoal = MSEtrain00/200 % R2train >= 0.995
net = newrb(Xtrain,Ytrain,MSEgoal)
Ytrain = net(Xtrain);
MSEtrain = mse(Ttrain-Ytrain)
R2train = 1- MSEtrain/MSEtrain00
%NONTRAINING SET OUTPUT
Ytest = net(Xtest);
%NONTRAINING SET PERFORMANCE IF TARGETS ARE KNOWN
MSEtest00 = repmat(mean(Ttest,2),1,Ntest)
MSEtest = mse(Ttest-Ytest)
R2test = 1- MSEtest/MSEtest00