[R] optim with upper and lower bounds

peter dalgaard pd@|gd @end|ng |rom gm@||@com
Tue Aug 11 09:48:46 CEST 2020


This stuff is of course dependent on exactly which optimization problem you have, but optimx::optimr is often a very good drop-in replacement for optim, especially when bounds are involved (e.g., optim has an awkward habit of attempting evaluations outside the domain when numerical derivatives are needed).

You might want to look at the last examples in ?stats4::mle (in R 4.x.x)

-pd

> On 10 Aug 2020, at 22:08 , Roy Mendelssohn - NOAA Federal via R-help <r-help using r-project.org> wrote:
> 
> I am running a lot of optimization problems, at the moment using 'optim'  ('optim' is actually called by another program).  All of the problems have variables with simple upper and lower bounds,  which I can easily transform into a form that is unconstrained and solve using 'BFGS'.  But I was wondering is if it is more robust to solve the problem this way,  or to use L-BFGS-B instead.
> 
> Also how much difference can it make using 'optimx' instead 'optim'?  The program I am using (KFAS) allows this,  I just have to do some extra programming to use it.
> 
> Thanks,
> 
> -Roy
> 
> 
> 
> **********************
> "The contents of this message do not reflect any position of the U.S. Government or NOAA."
> **********************
> Roy Mendelssohn
> Supervisory Operations Research Analyst
> NOAA/NMFS
> Environmental Research Division
> Southwest Fisheries Science Center
> ***Note new street address***
> 110 McAllister Way
> Santa Cruz, CA 95060
> Phone: (831)-420-3666
> Fax: (831) 420-3980
> e-mail: Roy.Mendelssohn using noaa.gov www: https://www.pfeg.noaa.gov/
> 
> "Old age and treachery will overcome youth and skill."
> "From those who have been given much, much will be expected" 
> "the arc of the moral universe is long, but it bends toward justice" -MLK Jr.
> 
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd.mes using cbs.dk  Priv: PDalgd using gmail.com



More information about the R-help mailing list