Re: [R] a question on R optimization functions

From: Ravi Varadhan <rvaradhan_at_jhmi.edu>
Date: Fri, 25 Mar 2011 16:50:15 -0400

Ben,

I am a huge fan of the old-fashioned and low-tech `cat'; it is good to know that I am not alone in this!

Ravi.



Ravi Varadhan, Ph.D.
Assistant Professor,
Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University

Ph. (410) 502-2619
email: rvaradhan_at_jhmi.edu

-----Original Message-----
From: r-help-bounces_at_r-project.org [mailto:r-help-bounces_at_r-project.org] On Behalf Of Ben Bolker
Sent: Friday, March 25, 2011 3:23 PM
To: r-help_at_stat.math.ethz.ch
Subject: Re: [R] a question on R optimization functions

Paul Gilbert <pgilbert <at> bank-banque-canada.ca> writes:

>
> It seems more likely that the return value from your function
> is NA or NaN or Inf. This might then result in an
> NA parameter value being calculated for the next step.
> This is possible, for example, because the line
> search extends outside the feasible region. You can
> re-write your function to check for that case and
> return a large negative value (or positive if minimizing),
> or stop() if that is more appropriate.
>
> Paul
>

  But it seems likely that if that happens the optimizer (optim, nlminb, whatever) would get to a state within the next few steps where it would stop with an error.

  Ravi suggests 'trace', which is a good idea. Having this happen in the middle of batch runs is a nuisance -- it rules out a lot of the interactive debugging tools -- but you can also use the old-fashioned, low-tech solution of adding lots of cat(...,"\n") statements to your objective function to see what's going on.



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.

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 Fri 25 Mar 2011 - 20:52:36 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 Fri 25 Mar 2011 - 21:10:24 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