Re: [R] Error handling in nlme call

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Thu, 31 Jan 2008 10:53:30 +0000 (GMT)

On Thu, 31 Jan 2008, Rob Forsyth wrote:

> In some trial simulation work I need to create batch files that will
> repeatedly generate pseudoreplicate datasets and then create non-
> linear mixed effects models using nlme. Inevitably these models
> sometimes fail to converge but I need the batch file to simply move on
> to another simulation rather than abort. I am using the try() function
> as in
>
> model<-try((nlme(...)))
>
> which handles reported errors such as the "Step halving in PNLS step"
> error well. On rare runs however the nlme function hangs without an
> error message. Aborting the script prompts a notification of multiple
> warnings and warnings() gives multiple recurrences of "Singular
> precision matrix in level -1, block 1". I understand why these occur
> but would like to trap these events too and simply move on to the next
> simulation. The try() function doesn't work presumably as no actual
> error message is reported during the run. Is there a way to test for
> this condition?

If it 'hangs' you don't have an error to trap. If you want to convert a warning to an error, use options(warn=2) or set a warning handler (see ?conditions).

> Thanks
>
> Rob Forsyth
>
> ______________________________________________
> 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.
>

-- 
Brian D. Ripley,                  ripley_at_stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
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.
Received on Thu 31 Jan 2008 - 10:56:32 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 31 Jan 2008 - 11:30:12 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive