[R] convergence

Julien Barnier julien at no-log.org
Thu Apr 19 14:36:45 CEST 2007


> how can i write a loop that makes algorithm keeps repeating until a solution
> is converged?do i use a for loop? i know that we can use for loop to ask for
> a number of repetitions, but how to use it to ask the algorithm to keep
> repeating until a solution is converged?

I don't know what your problem is, and I am far from being a specialist, but it
seems to me that in this case you often use a variable, for example 'epsilon',
which measures your "level of convergence". Then you could you use a loop which
repeats while this measure is above a certain threshold, for example :

while (epsilon > 0.0001) {
   ... repeated expressions ...

Hope that helps,


More information about the R-help mailing list