I've been calculating the RMSE between "A" and "B" as follows:
RMSE1=sqrt(mean((A-B).^2))
Where A is my "experimental data" and B is my predicted data, obtained from fitting.
I started using the function fitnlm for the fitting to try a non-linear model. And found that the RMSE that is calculated by the function is different than the one I calculate "by hand" as follows:
modelfun = @(Coeff,Vars)f(Vars);beta0=[Initial Coefficients starting point];mdl=fitnlm(Vars,A,modelfun,beta0)Coeff=table2array(mdl.Coefficients(:,1));B=modelfun(Coeff,Vars);RMSE=sqrt(mean((A-B).^2))
I was just wondering if anyone had any insight as to why this might be?
Thank you for your time.
P.S. I have also tried the following but get the same answer as RMSE1:
RMSE2=sqrt((sum((A-B).^2)/(size(A,1))))
Best Answer