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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Check the "try" command. Hope this helps, Matt -----Original Message----- From: Timothy R. Johnson [mailto:trjohns at uidaho.edu] Sent: Wednesday, April 17, 2002 2:54 PM To: r-help at stat.math.ethz.ch Subject: [R] nls error control 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._. _._ ------------------------------------------------------------------------------ Notice: This e-mail message, together with any attachments, contains information of Merck & Co., Inc. (Whitehouse Station, New Jersey, USA) that may be confidential, proprietary copyrighted and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by e-mail and then delete it. ============================================================================= -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._