Goodness of fit parameters seem to be incorrect in Curve Fitter App with Exponential 2 term
1 view (last 30 days)
Show older comments
Residual plot, RSquared, etc., seem to be incorrect. Residuals are too small and RSquared is showing as 1, although my hand calculation suggests 0.99993. Five (x,y) points were used and .mat file is attached. Note: .sfit file could not be attached due to upload restrictions. This could also be a bug.
Other considerations:
- Online Basic version
- Exponential 2 term
- Error is there with any variation of Advanced Options checked
0 Comments
Accepted Answer
Matt J
on 20 Oct 2023
Edited: Matt J
on 20 Oct 2023
RSquared is showing as 1, although my hand calculation suggests 0.99993
Not mine. See below. If I had to guess, you copied the a,b,c,d estimates off the screen for your hand calculation. That would be wrong, because the display only gives you the parameters to a limited number of decimal places.
load('Calibration1.mat');
[x,y]=deal(Calibration1_Ohm,Calibration1_Cond);
[fobj,gof] = fit(x,y,'exp2');
coeffs=num2cell(coeffvalues(fobj));
[a,b,c,d]=deal(coeffs{:});
yfit=a*exp(b*x)+c*exp(d*x);
rsquare=1 - sum((y-yfit).^2)/sum((y-mean(y)).^2)
isequal(rsquare, gof.rsquare)
More Answers (1)
the cyclist
on 20 Oct 2023
You are fitting 5 data points, using a function that has 4 free parameters. Furthermore, fitting with a double-exponential is problematic, because one of your Y values is zero, which means there is going to be a pathological attempt to balance the exponentially decaying functions, neither of which can ever equal zero. (I'm a little surprised that either a or c is not negative.)
Of course the R^2 is going to be extraordinarily close to 1, because that is just a comparison with the baseline model of picking the average Y. It's a pretty meaningless statistic here. It's a meaningless quibble about the precision of R^2, given the precision of your inputs.
Your goal here is unclear to me, but there is a lot to worry about in your approach here.
load("Calibration1.mat","Calibration1_Cond","Calibration1_Ohm");
format long
[f2,gof2] = fit(Calibration1_Ohm,Calibration1_Cond,'exp2')
2 Comments
Alex Sha
on 21 Oct 2023
The best result should be:
Sum Squared Error (SSE): 16466.8958529107
Root of Mean Square Error (RMSE): 57.3879706086749
Correlation Coef. (R): 0.999999804532598
R-Square: 0.999999609065233
Parameter Best Estimate
--------- -------------
a 1886.91142380654
b -0.000679491560501622
c 228169.088577397
d -0.0479054395023333
See Also
Categories
Find more on Descriptive Statistics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!