MathGroup Archive 2005

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

Search the Archive

Re: nonLinearFit and nonLinearRegress

  • To: mathgroup at
  • Subject: [mg55332] Re: [mg55298] nonLinearFit and nonLinearRegress
  • From: DrBob <drbob at>
  • Date: Sat, 19 Mar 2005 04:46:03 -0500 (EST)
  • References: <>
  • Reply-to: drbob at
  • Sender: owner-wri-mathgroup at

Without data, we have no way of experimenting with your code to solve the speed issue.

We might invent our own data, but how would we know whether YOUR data is meaningfully different for the NonlinearFit you're doing?

Also, we don't know the value of 'B', 'inf' , 'pi', or 'estimateQ', and the definition of h[B] has a botched Method option and lacks a pattern on the left. I suggest converting code to InputForm (under the Cell menu) and copy-pasting into e-mail, to avoid introducing typos.

If b doesn't depend on c, d, and q -- and you haven't told us they do -- then neither does h[b], so the holts function is the integral of a constant over an interval.

h[b_] := (1/(b*Pi))*
       {x, 0, Infinity},
       Method -> Oscillatory]);
holts[c_, d_, q_] := h[b](d - c)/q;

(I guessed the vales of 'inf' and 'pi'.)

Hence your fit function is linear in d, c, and 1/q. Surely one or both of these would go quickly (for given values of b and fitData):

NonlinearFit[fitData, h[b](d - c)/q, {c, d}, {q, estimateQ}]


NonlinearFit[fitData, h[b](d - c)qInverse, {c, d}, {qInverse, 1/estimateQ}]/.qInverse->1/q

I can't test either method, of course.

Finally, h[b] can be computed symbolically for some values:

h[b_] = FullSimplify[(2/(b*Pi))*
      {x, 0, Infinity}], Re[b^3] > 0]

F1Regularized[1/3, -((2*I*b^3)/
           27)] + 9*2^(1/3)*
zed[1/3, (2*I*b^3)/27] +
ized[5/3, -((2*I*b^3)/27)] -
ized[5/3, (2*I*b^3)/27])) +
       {1}, {1/3, 2/3, 5/6, 7/6},

You should verify this integral in the range you need before using it, but NIntegrate is just as good anyway, as b is a constant in the fit you're doing.


On Fri, 18 Mar 2005 05:34:55 -0500 (EST), John Hawkin <john.hawkin at> wrote:

> I'm trying to do a nonLinear fit on some data, fitting a parameter
> which appears in the limits of the integral that I'm trying to fit.
> When I do a nonLinearFit, I get about a page of errors, but it does
> work.  It takes about 10 minutes to do it for 20 points with a
> reasonable initial estimate.  However when I use the nonLinearRegress
> command, even with the best fit parameter from nonLinearFit given as
> the initial guess, it takes hours to work.  Is it possible there is a
> way to speed this up, and is this normal?
> The commands that I'm using to integrate this function are:
> h[B]:=2/(B pi) NIntegrate[x Sin[x] Exp[-(x/B)^3/2], {x, 0, inf},
> Method-Oscillatory];
> holts[c_, d_, Q_]:= NIntegrate[h[B], {B, c/Q, d/Q}];
> where holts is the function I am fitting (the h[B] integral is known
> as the Holtsmark integral).  The fitting command I'm using is:
> NonlinearFit[fitData, holts[c,d,Q], {c,d}, {Q, estimateQ}];
> where fitData contains sets of size 3, with the values of c and d as
> the first two values, and the data point that I'm fitting the integral
> to as the 3rd value.  If anyone has any ideas on how I can perform the
> nonlinear regression fast enough so that I can do it many times (maybe
> 50), I would greatly appreciate it.  Thanks very much,
> John Hawkin

DrBob at

  • Prev by Date: Re: nonLinearFit and nonLinearRegress
  • Next by Date: Re: Add new option to Notebook[]
  • Previous by thread: nonLinearFit and nonLinearRegress
  • Next by thread: Re: nonLinearFit and nonLinearRegress