MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Unstable solutions to NonlinearFit

Without having your data sets to work with it is difficult to give
specific details.  But what you describe is a common topic when
working with nonlinear fits.

My first hint would be to look at your initial "guesses" for the
parameters.  In your case these are: {{b, -1}, {c, -1}, {d, -1}, {f,
-1}}.  By examining a data set can you give mathematica starting
parameters that are nearer to what gives you a reasonable fit.  If
your initial guesses are far from the "correct" values the code may be
getting stuck in a local minimum that is far from the best solution.

ANother thing to try.  In your function Exp[b r1^2] + Exp[c + d r1] +
10^f,  I would avoid the 10^f.  Such a term means that small changes
in f will result in very large changes in the "constant" term.  This
can cause difficulties in nonlinear fits.  You might try replacing it
by a simple constant say g, let Mathematica do the fit then convert g
into your paramter f at the end via f = Log[g].

In a similar manner.  Exp[c + d r1] can be rewritten as Exp[c]Exp[d
Have a new parameter say "amp" = Exp[c] then fit to:
 Exp[b r1^2] + amp*Exp[d r1] + g.

I won't promise this will work.  But it is worth a try.  My experience
is that you sometimes have to play around with nonlinear fits and see
what happens.


ashcroft at (Peter Ashcroft) wrote in message news:<a2b4lp$ljd$1 at>...
> I'm having trouble using the NonlinearFit function to
> find the best fit for some data.  I get answers, but
> in some cases they appear nonsensical.  Also, I notice
> that the Confidence Intervals are *very* large for some
> of the parameters.
> The data in question describes antenna gain patterns, and
> has a very large dynamic range.  I suspect that this large
> range of data values (from 10^-8 to 1) is the reason that
> some of the parameters are estimated so badly.
> Simply looking at a plot of the data on a logarithmic
> scale suggests that it could be fit well by something of
> the form: Exp[b r1^2] + Exp[c + d r1] + 10^f
> (In other words, the data has an Exp[b r1^2] part for
> small values of r1, a slowly diminishing Exp[c + d r1]
> part for larger values of r1, and eventually plateaus
> at some constant positive value.)
> Here's an example where the fit doesn't turn out so well,
> (as judged by a plot of the fit on a logarithmic scale,
> and the confidence intervals that are very large).
> NonlinearRegress[linearvpairs,  
>   Exp[b r1^2] + Exp[c + d r1] + 
>     10^f, {r1}, {{b, -1}, {c, -1}, {d, -1}, {f, -1}}, 
>   RegressionReport -> {BestFit, AsymptoticCorrelationMatrix, 
>       ParameterCITable}]
> BestFit -> 
>       3.649189*10^-9 + E^(-16.209103 - 4.15162 r1) + E^(-4.106467 r1^2)
> ParameterCITable->	Estimate	Asymptotic SE	CI
> 		b	-4.1064		0.0139	        -4.13384,-4.0790
> 		c	-16.209		30903.73	-60595.3,60562.8
> 		d	-4.1516		236105.04	-462829.,462821.
> 		f	-8.4378		5643.3565	-11070.8,11053.9
> Note that "b" has a tight cinfidence interval, but the others 
> are extremely large.
> Here's another example that's even more pathological.  I don't
> know what subtlety of the data differentiates this case from the
> one above.  (All the data sets look fairly similar on visual 
> inspection.)
> NonlinearRegress[linearhpairs,  
>   Exp[b r1^2] + Exp[c + d r1] + 
>     10^f, {r1}, {{b, -1}, {c, -1}, {d, -1}, {f, -1}}, 
>   RegressionReport -> {BestFit}]
> BestFit -> 
>     3.772468*10^-313 + E^(-3.974 r1^2) + E^(-22.626 + 1.698 r1)
> Note the 10^-313!  I couldn't even compute the confidence
> intervals in this case.
> I know that I could get much better behaved fits if I
> fitted to the logarithm of the data rather than the
> data itself, but I would prefer to fit to the data
> directly if possible.  (Reasoning that what I want to
> minimize is the sum of the squared error in power
> rather than the squared error in log of the power.)
> Does anyone have any suggestions for how I might set
> the NonlinearFit options in order to get more stable
> results?  Thanks.

  • Prev by Date: How to separate imaginary unit inside an arbitrary function?
  • Next by Date: buttons
  • Previous by thread: Unstable solutions to NonlinearFit
  • Next by thread: Re: Unstable solutions to NonlinearFit