Start point power law fit
3 views (last 30 days)
Show older comments
Hi all,
Within the "Help" documentation I can read that for fitting a power law matlab uses optimized start points that are calculated heuristically. For the code I'm writing I need to have a fit for a lot of different datasets. It is easy to implement the code for fitting a power law curve. But my question is what should I do with the start points? I'm currently leaving the value empty, but I'm not certain what matlab does in that case. Does it calcalute start points as said in the "Help" file? Or should I and how? Provide startpoints myself?
0 Comments
Answers (1)
John D'Errico
on 12 Oct 2018
I'm not positive what tools you are using for the fit. I will assume the curve fitting toolbox.
Almost all optimizers (nonlinear regression tools) ask you to supply a set of starting values. Well, they should do that, at least I would argue that. The curve fitting toolbox does not force you to supply starting values, so I guess that is what you are using. And starting values can be crucial to the performance of an optimization/curve fit, so if it were my choice, I would make it necessary for you to provide them, or at least, more obvious that you need to provide them.
The CFT makes it seem that you don't really need start points. And I'll admit that for many model types you don't. But what does fit actually do? The help for fit tells you, here:
To fit the 1st equation in the curve fitting library of exponential
models (a single-term exponential), overriding the starting point to be
p0:
curve = fit( x, y, 'exp1', 'StartPoint', p0 );
Remarks on starting points:
For rational and Weibull models, and all custom nonlinear models, the
toolbox selects default initial values for coefficients uniformly at
random from the interval (0,1). As a result, multiple fits using the
same data and model may lead to different fitted coefficients. To avoid
this, specify initial values for coefficients with FITOPTIONS or a
vector value for the StartPoint property.
So, you can use the FITOPTIONS tool to indicate starting values. Simpler is to use the StartPoint property, as in the example given. So it is not that really hard to find out how to give starting values, except that to find it, you needed to read down to the very end of the help.
Anyway, random startpoints in [0,1] are IMHO, a bad idea. Much of the time, especially with anything that involves an exponent in any form, a random starting point from the interval [0,1] ends up as a poor choice. However, I'll admit that since many models that fit provides do not need a starting value at all, fit cannot force you to provide starting values for all models. So the way that fit is written is how I might have chosen to implement it myself, using a property/value pair to give the starting point. I would just make it far more clear that you really do need to provide starting values for many models, and how to do that, IF I were writing the code and the help docs. End of rant, lol.
See Also
Categories
Find more on Linear and Nonlinear Regression 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!