[R] a question on R optimization functions
Ravi Varadhan
rvaradhan at jhmi.edu
Fri Mar 25 21:50:15 CET 2011
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.
More information about the R-help
mailing list