Is that necessary to set the start points for fitting?
6 views (last 30 days)
Show older comments
Hi there, I am using Matlab 2012a and applying the cftool in fitting my data with 'exp2'. Since there are lots of data to be fitted, I create the code from the interaction cftool interface so things can be done automatically. However, I found that once the code was generated, the start points for fitting were fixed and some special numbers were used. Though all my data are of the shape of 'exp2' but they are more or less different. So if I used the same start points for fitting, will it return an inaccurate results? I try for some data, most of them are good but some of them are not. To verify that, I apply the generated code to one dataset and get the fitting parameter and then open cftool to fit the same set interactively, they give different fitting coefficients (but the fitting curve seems match up well). It is so confusing, how important is the start points in fitting? What happen if I use an 'empty' start points instead? (I tried too, seems doesn't make big difference).
Any, my question is how to fit different data set in a command-base code correctly without worrying about the start points? Thanks.
1 Comment
Jan
on 30 May 2018
[MOVED from section for answers] YANG PAN wrote:
I have met the same problem as yours, and can you tell me your solution at last?
@YANG PAN: Please do not post comments in the section for answers. It is unlikely that Ki will answer your question 6 years later.
Accepted Answer
Tom Lane
on 17 Jun 2012
Starting points can be very important in some cases.
Your analysis is correct. If you fit the 'exp2' model from the cftool GUI, the function tries to find starting points for you based on the data you provide. If you generate code, the code contains those starting points. This may not be appropriate if you use the code later with data having different characteristics. In that case, you can change the code so that it does not set the starting values. Then the same code will run that attempts to find good starting values for you based on your new data.
The need for good starting values is strongest for custom fit equations. There's no built-in code for finding good starting values for equations you enter yourself.
3 Comments
Tom Lane
on 19 Jun 2012
It's difficult to say whether a different x range would require a different set of starting values. If you think the original fit is likely to be a reasonable model for the new data, that might be a reason to stick with the starting values stored in your generated code. But without any other information, I'd recommend deleting the line of code that sets the starting values, and let the Curve Fitting Toolbox functions try to find appropriate ones.
John D'Errico
on 30 May 2018
Way too late, but a point that I think important, and since this question has been revived...
Exponential models are the classic case of needing GOOD starting values. Poor starting values too often result in either underflows or overflows, both of which kill the computations, making the fit one that simply will not converge.
Next, a multi-term exponential model MUST start with different starting values for the terms (mainly the rate constants), since if they are not distinct, then then system being solved becomes singular. So again, the fit will fail.
Next, if you have the wrong sign for the rate constant? Whoops! Again, probable failure.
Finally, even if you do have good starting values, with the proper signs on the rates, sums of exponentials are still a nasty model to fit, as the problem easily becomes poorly conditioned. So having good data (and enough of it) can be an imperative.
More Answers (0)
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!