cftool two term exponential curve fit doesn't make sense
6 views (last 30 days)
Show older comments
Matthew Pollard
on 26 Mar 2015
Answered: John D'Errico
on 26 Mar 2015
Hey all. So I'm curve fitting some experimental data in MatLAB using the cftool. This is in R2014b. I'm fitting my data to a two term exponential function such that f(x) = a*exp(b*x) + c*exp(d*x). The curve on the plot looks good. My R squared values are 0.99 . . . but the coefficients make no sense.
a = 4.097e+07
b = -4.806
c = -4.097e+07
d = -4.806
Based on the above formula for a two term exponential, for an x value f(x) = 0. I can't extract these coefficients and use them elsewhere because they don't make sense and they don't produce the curve fit that cftool graphs that has the R^2 = 0.99 . . . Am I missing something?
0 Comments
Accepted Answer
John D'Errico
on 26 Mar 2015
It is good to think about the parameters that come back. Does what you got make sense? Never just accept what a computer gives you without applying a mental filter to it.
So, what has happened here? It turns out that IF you look carefully at the parameters, to full precision, you will see a difference. The differences between those terms is tiny, and with those huge coefficients, it tells me that the solver managed to overfit the problem. Sadly, this fit is meaningless, and I would argue useless. You might as well use a spline, or some other tool.
If you really are wedded to an exponential model BECAUSE the parameters are necessary for other purposes, then these coefficients are useless anyway. They have no meaning, EXCEPT that they managed to squeeze a slightly lower residual error out of the model, FOR that set of data. Yes, sometimes people need a rate parameter from a model, and this is why they use an exponential model. But those model parameters offer no meaning at all in that context.
I'd prefer to play with the data (or at least look at it) before trying to suggest a better model. But essentially, if your goal is purely to get a good fit, then use a tool that can fit your data well instead of trying to force an exponential model to fit by just throwing extra parameters at the curve fit. My suggestion would probably be a spline model, specifically my SLM toolbox (found on the File Exchange), because you can control the basic shape of that curve.
0 Comments
More Answers (1)
Star Strider
on 26 Mar 2015
We can’t see all the digits in the coefficients you posted. Are they truly equal? Perhaps you only need one exponential.
2 Comments
Star Strider
on 26 Mar 2015
I can’t imagine that you would need an R² value higher than 0.97 with real-world data. The criteria of interest are the residual sum-of-squares, and more importantly, the confidence intervals of the parameters.
Pay close attention to the confidence intervals of the parameters. If any of them include zero (one positive an one negative) that parameter is not needed in the model. That will tell you if you need all the parameters from both exponentials.
You can get more figures in the coefficients (and everything else) by choosing format long e in the Command Window or your script file.
See Also
Categories
Find more on Interpolation 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!