Dear all, I have a for loop which includes nls model estimation. The loop breaks after the first non-convergence error. How can I make the loop continue and try to estimate all models? I suppose it should be sth like: if(...) { next } but I have no idea how to setup the arguements... Thank you! Irene
take a look at the try() command. b On Oct 9, 2007, at 11:41 AM, Irene Mantzouni wrote:> Dear all, > > I have a for loop which includes nls model estimation. > The loop breaks after the first non-convergence error. > How can I make the loop continue and try to estimate all models? > I suppose it should be sth like: if(...) { next } > but I have no idea how to setup the arguements... > > Thank you! > > Irene
Hi, See ?try On 09/10/2007, Irene Mantzouni <ima@difres.dk> wrote:> > Dear all, > > I have a for loop which includes nls model estimation. > The loop breaks after the first non-convergence error. > How can I make the loop continue and try to estimate all models? > I suppose it should be sth like: if(...) { next } > but I have no idea how to setup the arguements... > > Thank you! > > Irene > > > ______________________________________________ > 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. >-- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[alternative HTML version deleted]]
Thank you all! Yes, try works!
It is also possible to pass the control argument of nls "warnOnly=TRUE", which indicates that an object should be returned if stopping criteria are met (e.g., reaching a max. number of iterations). See help(nls.control) for more info. On Tue, 9 Oct 2007, Irene Mantzouni wrote:> Thank you all! > Yes, try works! > > ______________________________________________ > R-help at 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. >
It's a FAQ: 7.32. -thomas On Tue, 9 Oct 2007, Irene Mantzouni wrote:> Dear all, > > I have a for loop which includes nls model estimation. > The loop breaks after the first non-convergence error. > How can I make the loop continue and try to estimate all models? > I suppose it should be sth like: if(...) { next } > but I have no idea how to setup the arguements... > > Thank you! > > Irene > > > ______________________________________________ > R-help at 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. >Thomas Lumley Assoc. Professor, Biostatistics tlumley at u.washington.edu University of Washington, Seattle