Effacer les filtres
Effacer les filtres

Goodness of fit parameters seem to be incorrect in Curve Fitter App with Exponential 2 term

2 vues (au cours des 30 derniers jours)
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

Réponse acceptée

Matt J
Matt J le 20 Oct 2023
Modifié(e) : Matt J le 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)
rsquare = 1.0000
isequal(rsquare, gof.rsquare)
ans = logical
1

Plus de réponses (1)

the cyclist
the cyclist le 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')
f2 =
General model Exp2: f2(x) = a*exp(b*x) + c*exp(d*x) Coefficients (with 95% confidence bounds): a = 7123 (7123, 7123) b = -0.003526 (-0.003526, -0.003526) c = 739.5 (739.4, 739.5) d = -0.0001828 (-0.0001828, -0.0001828)
gof2 = struct with fields:
sse: 7.067779991157303e-07 rsquare: 0.999999999999909 dfe: 1 adjrsquare: 0.999999999999637 rmse: 8.407008975347477e-04
  2 commentaires
Dustin
Dustin le 20 Oct 2023
Thanks for the assessment.
Context. The goal is to fit data for a conductivity sensor. A power law generally works well through majority of range, but won't go to zero, or near enough to zero. Accuracy around this range is important, so I'm hunting around for alternative functions. I was hoping for something that holds its shape, as opposed to a polynomial.
As noted in other answer, looks like my hand calculation precision was off.
Alex Sha
Alex Sha le 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

Connectez-vous pour commenter.

Produits


Version

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by