Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

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

Search the Archive

Re: NonlinearRegress fitfail error

  • To: mathgroup at smc.vnet.net
  • Subject: [mg89352] Re: NonlinearRegress fitfail error
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Sat, 7 Jun 2008 02:56:18 -0400 (EDT)
  • Organization: The Open University, Milton Keynes, UK
  • References: <g2b4pu$nn4$1@smc.vnet.net>

Meaghan wrote:
> I'm updating an old program to Mathematica 6.  Here's the problem
> code:
> 
> Needs["NonlinearRegression`"]
> 
> msoln = BestFitParameters /.
>   NonlinearRegress[part1, a2*(Exp[b2*x] - 1) + c2*x, startpoints, x,
>    AccuracyGoal -> 5, PrecisionGoal -> 5, MaxIterations -> 500,
>    RegressionReport -> BestFitParameters]
> where "part1" is a long list of data points.
> 
> I know this method of replacement was valid in 5.2, but here I get:
> FindFit::nrlnum: The function value {0.+(-1.+2.71828^(0. b2)) a2+0.
> c2,0.104632+(-1.+2.71828^(0.195816 b2)) a2+0.195816 c2,<<8>>,<<92>>}
> is not a list of real numbers with dimensions {102} at {a,b,c} =
> {0.0369002,0.32,0.158379}.
> NonlinearRegress::fitfail: The fitting algorithm failed.
> ReplaceAll::reps: "{msoln} is neither a list of replacement rules nor
> a valid dispatch table, and so cannot be used for replacing."

My understanding is that you have forgotten to tell Mathematica what are 
the parameters of the model, i.e. the symbol *startpoints* is not 
defined or contains an erroneous definition. You should set it to, or 
replace it by,{a2, b2, c2}.

In[40]:= Needs["NonlinearRegression`"]
(* The following data are phony! This is just for the sake of the 
example about parameter definition. *)
part1 = {{2, -0.99}, {6, -0.7}, {10, 0.58}, {14, 0.41}, {18, -0.66}};
startpoints = {a2, b2, c2};
msoln = BestFitParameters /.
   NonlinearRegress[part1, a2*(Exp[b2*x] - 1) + c2*x, startpoints, x,
    AccuracyGoal -> 5, PrecisionGoal -> 5, MaxIterations -> 500,
    RegressionReport -> BestFitParameters]

During evaluation of In[40]:= FindFit::cvmit: Failed to converge to \
the requested accuracy or precision within 500 iterations. >>

Out[43]= {a2 -> -3.37398*10^-19, b2 -> 2.3599, c2 -> 0.0159547}



  • Prev by Date: Re: Why don't my plots appear? My 5.2 code no longer works
  • Next by Date: Re: Integral Questions
  • Previous by thread: Re: NonlinearRegress fitfail error
  • Next by thread: Inequalities or histogram or something.......