[R] convergence

Ravi Varadhan rvaradhan at jhmi.edu
Thu Apr 19 16:31:58 CEST 2007


No.

----------------------------------------------------------------------------
-------

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: rvaradhan at jhmi.edu

Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html

 

----------------------------------------------------------------------------
--------

-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Alberto Monteiro
Sent: Thursday, April 19, 2007 9:24 AM
To: ted.harding at manchester.ac.uk; r-help at stat.math.ethz.ch
Subject: Re: [R] convergence


Ted Harding wrote:
> 
> There are various ways round this, but a 'for' loop with
> a fixed number of iterations is not usully one of them!
> 
> The simplest is to use while(). A possibly strategy is
> 
>   Y.old <- initial.Y
>   while(TRUE){
>     Y <- compute.Y(Y.old, ...)
>     if(abs(Y - Y.old) < small.number) break
>     Y.old <- Y
>   }
> 
> This will loop indefinitely until the convergence criterion
> 
>   abs(Y - Y.old) < small.number
> 
> is met, and then stop.
> 
I guess some precaution must be taken to prevent that the loop
runs forever.

Those algorithms that must optimize something, but run the risk 
of running forever, sound like the "chess playing" engine: we
know that a deterministic solution exists (there is a finite number
of chess positions), but it's not practical to check all of them.

I read somewhere that computer loop problems are treated as if
the computer was "playing chess" agains Murphy: it tries hard to
solve the problem, but sometimes he must give up a path and backtrack
to a less optimum but faster solution.

Do I make any sense?

Alberto Monteiro

______________________________________________
R-help at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list