Nonlinear fitting is not guaranteed to converge to the global optimum (the
solution with the smallest sum of squared residuals, SSR), and can get stuck
at a local minimum. The routine has no way to determine that; it is up to
you to judge whether this has happened.
`fit` (Note:fit ) may, and often will get "lost" if started far from a
solution, where SSR is large and changing slowly as the parameters are varied,
or it may reach a numerically unstable region (e.g., too large a number
causing a floating point overflow) which results in an "undefined value"
message or `gnuplot` (Note:gnuplot ) halting.
To improve the chances of finding the global optimum, you should set the
starting values at least roughly in the vicinity of the solution, e.g.,
within an order of magnitude, if possible. The closer your starting values
are to the solution, the less chance of stopping at another minimum. One way
to find starting values is to plot data and the fitting function on the same
graph and change parameter values and `replot` (Note:replot ) until
reasonable similarity is reached. The same plot is also useful to check
whether the fit stopped at a minimum with a poor fit.
Of course, a reasonably good fit is not proof there is not a "better" fit (in
either a statistical sense, characterized by an improved goodness-of-fit
criterion, or a physical sense, with a solution more consistent with the
model.) Depending on the problem, it may be desirable to `fit` with various
sets of starting values, covering a reasonable range for each parameter.