[R] nls error control

Ole Christensen o.christensen at lancaster.ac.uk
Wed Apr 17 21:15:51 CEST 2002


Hi Tim

Maybe ``try'' is be the solution to your problem.

The follwoing silly example illustrates the use (error messages are
printed but there is no crash)

for(i in 1:10){
 x <- try(chol(matrix(NA,2,2)))
 print(i)
}


Cheers Ole


"Timothy R. Johnson" wrote:
> 
> I'm running a simulation that uses nls on each run. Sometimes, not
> unexpectedly, nls doesn't return parameter estimates (e.g., "singular
> gradient" error). Of course when this happens the simulation (in a loop)
> stops and no results are recorded. What I would like is for the simulation
> to simply record that nls couldn't obtain estimates on a particular run due
> to whatever difficulties it encountered but to not return an error that
> stops the entire simulation.
> 
> Has anyone worked-out a tweak to do this? I'm using version 1.4.1 under
> Linux.
> 
> Best regards,
> 
> Tim Johnson
> 
> ---------------------------------
> Assistant Professor of Statistics
> University of Idaho
> Moscow, Idaho 83844-1104
> trjohns at uidaho.edu
> http://www.uidaho.edu/~trjohns
> 
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

-- 
Ole F. Christensen
Department of Mathematics and Statistics
Fylde College, Lancaster University 
Lancaster, LA1 4YF, England
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list