Clear Filters
Clear Filters

Different RMSE using fit.m

2 views (last 30 days)
Nils
Nils on 15 Dec 2016
I'm trying to understand how fit.m computes the RMSE when using a Robust Power Law. I noticed that I cannot compute the SSE according to the documentation (<https://www.mathworks.com/help/curvefit/evaluating-goodness-of-fit.html Evaluating Goodness of Fit>).
x = [1:10]';
y = [0.25;0.42;0.84;1.60;2.46;3.59;4.90;5.68;7.46;10.14];
% Robust Power Law fit
% fo -> fit
% gof -> goodness of fit
% fai -> fitting algorithm information
[fo,gof,fai]=fit(x,y,'power1', 'Robust', 'LAR');
% According to fit
disp(gof);
% sse: 0.1923
% dfe: 8
% rmse: 0.1551
% According to documentation & Wikipedia
dfe = fai.numobs - fai.numparam; % 8
sse = sum(abs(fai.residuals).^2); % 1.1111
mse = sse/dfe; % 0.1389
rmse = sqrt(mse); % 0.3727
I looked at the curve fitting toolbox code, and realize that the SSE was computed in private/cfrobnlinfit.m in another way.
% Shrink robust value toward ols value if appropriate
sigma = max(robust_s, sqrt((ols_s^2 * P^2 + robust_s^2 * N) / (P^2 + N)));
resnorm = dfe * sigma^2; % new resnorm based on sigma
I did not find any documentation on this formula, could you indicate me why it is computed using those equations? And where is the documentation of those functions ? Thank you !

Answers (0)

Community Treasure Hunt

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

Start Hunting!