[18862] in s-news-athena

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

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

daemon@ATHENA.MIT.EDU (Henrik Aalborg-Nielsen)
Thu Aug 5 04:05:54 1999

Date: Thu, 5 Aug 1999 08:50:48 +0200 (METDST)
From: Henrik Aalborg-Nielsen <immhan@student.dtu.dk>
To: ROS Mathieu <mim78@cict.fr>
Cc: s-news@wubios.wustl.edu
In-Reply-To: <Pine.SGI.3.95.990804090248.12601A-100000@ondine.cict.fr>
Message-Id: <Pine.HPP.3.95.990805083901.20118A-100000@srv4.gbar.dtu.dk>
Mime-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII


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.

On Wed, 4 Aug 1999, ROS Mathieu wrote:

> hello Splus users,
> 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 ?
> any help will be appreciated
>        
>        Mathieu

Regards,
Henrik

--------------------------------------------------------------------------
Henrik Aalborg Nielsen                  
Department of Mathematical Modelling
Section for Statistics			Fax:	+45 4588 1397
Time Series Group			Phone:	+45 4525 3418
Technical University of Denmark		E-mail:	han@imm.dtu.dk
Building 321, 2800 Lyngby, Denmark	URL:	http://www.imm.dtu.dk/~han
--------------------------------------------------------------------------


-----------------------------------------------------------------------
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