[R] relative convergence in 'optim'

Mauricio Zambrano-Bigiarini hzambran.newsgroups at gmail.com
Tue Nov 6 00:10:28 CET 2012


2012/11/5 Mauricio Zambrano-Bigiarini <hzambran.newsgroups at gmail.com>:
> Dear list,
>
> I have a question related to the correct interpretation of the
> relative convergence criterion used by 'optim'.
>
>
> In the help of the function is it written that:
>
> "reltol:Relative convergence tolerance. The algorithm stops if it is
> unable to reduce the value by a factor of reltol * (abs(val) + reltol)
> at a step."
>
> and I was wondering if the previous criterion is equivalent to:
>
>
> abs( val [iter] - val[iter-1] ) / val [iter-1] <= reltol * ( abs( val
> [iter] ) + reltol )
>
> OR
>
> abs( val [iter] / val [iter-1] ) <= reltol * ( abs( val [iter] ) + reltol )
>
> OR
>
> abs( val [iter] - val [iter-1] ) <= reltol * ( abs( val [iter] ) + reltol )


Just in case it be useful for somebody else.

>From the C code on http://svn.r-project.org/R/trunk/src/appl/optim.c :

...
enough = (f > abstol) &&
fabs(f - *Fmin) > reltol * (fabs(*Fmin) + reltol);
   /* stop if value if small or if relative change is low */
   if (!enough) {
count = n;
*Fmin = f;
   }
...

which I would write in R as:

reltol <- abs( f - f.best ) <= reltol * ( abs(f.best) + reltol )



Cheers,

Mauricio Zambrano-Bigiarini

--
=====================================
Water Resources Unit
Institute for Environment and Sustainability
Joint Research Centre, European Commission
webinfo    : http://floods.jrc.ec.europa.eu/
=====================================
DISCLAIMER:\ "The views expressed are purely those of th...{{dropped:11}}




More information about the R-help mailing list