Hi Bill,

You should have a look at the try() function that lets you enclose an
expression and handle failure in a way that prevents the entire execution
from halting.

Josh

On Thu, Mar 12, 2009 at 1:13 PM, Bill Shipley
<bill.shipley@usherbrooke.ca>wrote:

> Hello.  I have a script in which I repeatedly fit a nonlinear regression to
> a series of data sets using nls and the port algorithm from within a loop.
> The general structure of the loop is:
>
>  for(i in 1:n){
>
> … extract relevant vectors of dependent and independent variables …
>
> … estimate starting values for Amax and Q.LCP…
>
>
>
>
>
> fit<-nls(photosynthesis~fit.Mitcherlich(irradiance,Amax,LCP,Q.LCP),data=temp
> ,
>
>
> start=list(Amax=Astart,Q.LCP=x,LCP=33),control=list(maxiter=100,tol=5e-4),
>
>            na.action=na.omit,trace=T,algorithm="port",lower=c(0,0,0))
>
> …
>
> }
>
>
>
> Despite trying to estimate good starting values, the nls function
> occasionally experiences problems with convergence.  When this happens the
> function stops and prints an error message, thus preventing the loop from
> continuing.  Is there some what of detecting the convergence problem while
> preventing the nls function from stopping when this happens, so that the
> loop can continue?
>
>
>
> Bill Shipley
>
> North American Editor, Annals of Botany
>
> Département de biologie
>
> Université de Sherbrooke
>
> Sherbrooke (Québec) J1K 2R1
>
> Canada
>
> (819) 821-8000, poste 62079
>
> (819) 821-8049 FAX
>
>
>
> http://pages.usherbrooke.ca/jshipley/recherche/
>
>
>
>
>        [[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help@r-project.org 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.
>
>


-- 
Joshua Reich
646 256 4763
i2pi
simplicity . depth . scalability

	[[alternative HTML version deleted]]


