[R] issue with L-BFGS-B in optim (optim just hangs)

Ravi Varadhan RVaradhan at jhmi.edu
Wed Apr 15 17:32:34 CEST 2009


Hi Tiago,

It is hard for me to speculate without knowing more about your problem.  

Here is what I would suggest, assuming your problem specification and its
computer implementation are correct:

(1) You may try to terminate the algorithm by specifying a different
stopping criterion than the default values, and see whether the solution is
of acceptable accuracy.  You can increase "factr" and/or "pgtol" to see if
this problem goes away.  

(2) Another option is to increase "lmm" parameter, which is the number of
BFGS updates saved for approximating the hessian.  Results in Zhu et al.
(ACM 1997) show that increasing "lmm" tends to improve the reliability of
the algorithm.  Try, for example, lmm=17 (default is lmm = 5).  Also, try
using "trace" to get more information on what goes on. 

I can also suggest some alternative solutions:

(3).  An easy solution is to try a different optimization algorithm: YOU can
try either nlminb() or spg() in package "BB". 

(4).  If it is easy to do so, specify analytic score function, i.e. the
gradient of log-likelohood, and re-run optim() or nlminb() or spg().


Hope this helps,
Ravi.

----------------------------------------------------------------------------
-------

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: rvaradhan at jhmi.edu

Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html



----------------------------------------------------------------------------
--------


-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of Tiago Marques
Sent: Wednesday, April 15, 2009 10:57 AM
To: r-help at r-project.org
Subject: [R] issue with L-BFGS-B in optim (optim just hangs)

Dear R-Help List,

I am using optim, with method=L-BFGS-B, to maximize a likelihood inside a
large simulation exercise. This runs fine for most simulated data sets, but
for some reason, about 1 out of 100 times, optim will just hang.
Using a dumb approach to the problem (i.e. printing the parameter values
each time the function being maximized is evaluated), I tracked down when
this happens, and although I do not understand optim's behavior or what
triggers it, it seems to happen specifically when one of the parameter
boundaries is reached - and then the function just stops being evaluated.

But there is nothing special with the parameter boundary, i.e., if  I
decrease or increase the boundary using say lower and upper arguments in
optim, the function seems to hang at the new values. So it does not seem to
be a specific value that triggers the behavior, but the fact that the value
is the boundary defined in the function call.

As anyone seen this behavior before? Is it me missing something or is this
some bug in "method=L-BFGS-B"? Any suggestions on how to deal with it?

Many thanks for any useful feedback,

Tiago

--
____________________________________________________________________________
________________________ 

Tiago André Marques
Research Unit for Wildlife Population Assessment Centre for Research into
Ecological and Environmental Modelling University of St Andrews The
Observatory Buchanan Gardens St Andrews Fife KY16 9LZ Scotland

Tel: 00441334461842 Fax: 00441334461800 (Scotland office)
Tel: 00351210198736 (Portugal home)

http://www-maths.mcs.st-andrews.ac.uk/homepages/tam2.html
http://www.creem.st-and.ac.uk/tiago/

The University of St Andrews is a charity registered in Scotland : No
SC013532

______________________________________________
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