[18879] in s-news-athena

home help back first fref pref prev next nref lref last post

[S] summary : nls() fails in a loop

daemon@ATHENA.MIT.EDU (ROS Mathieu)
Fri Aug 6 11:03:58 1999

Date: Fri, 6 Aug 1999 16:56:30 +0200 (MET)
From: ROS Mathieu <mim78@cict.fr>
To: s-news@wubios.wustl.edu
Message-Id: <Pine.SGI.3.95.990806165145.7087A-100000@ondine.cict.fr>
Mime-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII


Even if the solution I finally found is a bit 'peculiar', I have learnt
many things from the answers I got. Many thanks to people who answered :
Patrick Burns, Henrik Aalborg-Nielsen ,Bill Venables, Tim Hesterberg, Douglas Bates,
Brian Ripley, Bruce McCullough.

I will not write here all the answers I received, but briefly summarize.

The original question was the following : 
"
I'm using nls() in a cross-validation loop (no way to avoid 
it now...) with 180 iterations but with my initial values
(start(a=-50,b=10,c=-0.009)) it stops after some iterations
with a 'step factor reduced below minimum' error.
How can I handle this problem without entering new starting 
points at each step ?
"

1. as Bill Venables recalls it first,
"Don't begin every cv fit with the original rough initial values.
Always use the best available initial values you have, for example,
from the primary fit using all the data."

so I add a nls() fit in the beginning of the function in order to compute
better initial values. 

2.I tried algorithm="plinear" option but this not helped me, nor
downloading nlme3.1 library (it was really awarding indeed).

3.I heard about the restart() and ignore.error functions but decided 
(wisely?) not to use them.

4.One of the ideas I used to deal with my problem came from Henrik 
Aalborg-Nielsen:
"Instead of restart(), which has been suggested by other readers of this
list, I would suggest a small modification of nls().  The idea is to
replace 'stop' in 

        if(z$control[5])
                stop(switch(as.integer(z$control[5]),
                        "step factor reduced below minimum",
                        "maximum number of iterations exceeded",
                        "singular gradient matrix",
                        "singular design matrix",
                        "singular gradient matrix"))
with 'return'.  In the function calling the modified nls() a test like 

        if(is.null(class(nls.output))) {
        <things to do in case of non-convergence>
        }
        else {
          <normal operation>
        }

will then be appropriate."

5. I must now comfess that the <things to do in case of non-convergence>
is a scanning of new starting points. I know this look a bit weird but I had to
find a quick solution as my internship will end in a week...

"neither approach is in general a valid one for a cross-validation" 
B. Ripley

----------------------------------------------------------------
Mathieu Ros
mathieuros@bigfoot.com
DESS ingenierie mathematique (biostatistiques)
Universite Joseph Fourier, Grenoble
----------------------------------------------------------------
La prevision est difficile, surtout quand elle concerne l'avenir

-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu.  To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message:  unsubscribe s-news

home help back first fref pref prev next nref lref last post