MathGroup Archive 2002

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

Search the Archive

RE: Use of ShowProgress Option output

  • To: mathgroup at smc.vnet.net
  • Subject: [mg34799] RE: [mg34783] Use of ShowProgress Option output
  • From: "Annetts, Dave (E&M, North Ryde)" <David.Annetts at csiro.au>
  • Date: Fri, 7 Jun 2002 01:09:04 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Hi Andre,

> ... may be my question was not clear in detail, but I realy 
> can't find a 
> solution.
> I will show you an example from the help browswer to 
> ilustrate my problem.
> 
> 
> data={{1.0,1.0,.126},{2.0,1.0,.219},{1.0,2.0,.076},{2.0,
>         2.0,.126},{.1,.0,.186}};
> 
> NonlinearRegress[data,
>   theta1 theta3 x1/(1+theta1 x1+theta2 
> x2),{x1,x2},{theta1,theta2,theta3},
>   RegressionReport->BestFitParameters,ShowProgress->True]

In essence, you want to retain the values of Chi^2 and your model
parameters?

Short of modifying the code in the package, I don't see how NonlinearRegress
is going to give you this so you'll need to do things "manually".

The idea is to loop, and append the results of each fit to a list which you
can plot.  

Something like the following block should get you started.

diff[chsq_, csqo_] := 100. * Abs[chsq - csqo]/chsq;
Off[FindMinimum::fmlim];
prog = {};
csqo = 1.;
i = 0;
{ith1, ith2, ith3} = {1., 1., 1.};

While[diff[chsq, csqo] > 1.,
  tmp = NonlinearRegress[data, th1 th3 x1 /(1 + th1 x1 + th2 x2),
      {x1, x2}, 
      {{th1, ith1}, {th2, ith2}, {th3, ith3}},
      RegressionReport -> {FitResiduals, BestFitParameters},
      MaxIterations -> 1
      ] ;
  i += 1;
  csqo = chsq;
  chsq = #^2 & /@ (FitResiduals /. tmp);
  chsq = Apply[Plus, chsq];
  
  Print["it = ", i, " ", chsq, " ", csqo, " ", diff[chsq, csqo], 
    " ", {ith1, ith2, ith3} ]; 
  
  ith1 = th1 /. (BestFitParameters /. tmp);
  ith2 = th2 /. (BestFitParameters /. tmp);
  ith3 = th3 /. (BestFitParameters /. tmp);
  lst = {chsq, {BestFitParameters /. tmp}};
  prog = AppendTo[prog, lst];
  ]

Points to note are:-
1.	The code is in no sense elegant or efficient -- I recall something
like this using FindMinimum in a FAQ on WRI's site so you may want to search
there further;
2.	For a given tolerance, altering MaxIterations gives you multiple
"bites" per step -- at 1, convergence is in 29 its but at 2, convergence is
in 5 steps.;
3.	Convergence rates are dependent upon both the definition of "diff"
and the tolerance;

Regards,

Dave.
--------------------------------------------------------
  Dr. David Annetts             EM Modelling Analyst
  Tel: (+612) 9490 5416         CSIRO DEM, North Ryde
  Fax: (+612) 9490 5467         David.Annetts at csiro.au
                 Include "usual_disclaimers"
--------------------------------------------------------


  • Prev by Date: Use of ShoWProgress option (part 2)
  • Next by Date: Re: Is it possible to access internal variables? [CompoundExpression]
  • Previous by thread: Use of ShowProgress Option output
  • Next by thread: Re: Use of ShowProgress Option output