Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generalized Reduced Gradient (GRG2) Algorithm in R

Tags:

optimization

r

Does anyone know which R package has the implementation of Generalized Reduced Gradient (GRG2) Algorithm ? thanks

like image 226
liujx80 Avatar asked Mar 02 '13 15:03

liujx80


2 Answers

Since @BenBolker has done the initial footwork in finding what sort of functionality you were hoping to replicate I'm posting a follow-up that might be useful. A recent exchange on Rhelp ended with a quote that was nominated for the R fortunes package, although it is not clear to me whether it was accepted:

"The idea that the Excel solver "has a good reputation for being fast
and accurate" does not withstand an examination  of the Excel solver's
ability to solve the StRD nls test problems. ...
Excel solver does have the virtue that it will always produce an
answer, albeit one with zero accurate digits."

"I am unaware of R being applied to the StRD, but I did apply S+ to the 
StRD and, with analytic derivatives, it performed flawlessly."

From:   Bruce McCullough <[email protected]>
Date:   February 20, 2013 7:58:24 AM PST

Here is a link to the self-cited work documenting the failures of the Excel Solver (which we now know is powered by some version of the GRG2 algorithm) by McCullough: www.pages.drexel.edu/~bdm25/chap8.pdf and the link to the NIST website for the testing problems are here: http://www.itl.nist.gov/div898/strd/nls/nls_info.shtml and http://www.itl.nist.gov/div898/strd/nls/nls_main.shtml

The negative comment (brought to my attention by a downvote) from @jwg prompted me to redo the search suggested by Bolker. Still no hits for findFn( "GRG2"). I can report several hits for "GRG" none of them apparently to a solver, and was amused that one of them has the catchy expansion to "General Random Guessing model". That seemed particularly amusing when the thrust of my arguably non-answer was that choosing to use Excel's solver left one genuinely uncertain about the accuracy of the solution. I am unrepentant about posting an "answer" that does not deliver exactly what was requested, but instead warns users who might not be religiously committed to the Microsoft way in this statistical/mathematical arena. The lack of any effort on the part of the distributed R developers to provide a drop-in-replacement for the Excel solver is something to ponder seriously.

like image 84
IRTFM Avatar answered Nov 12 '22 18:11

IRTFM


Some relavant insights come from this post to R-help by a reputable statistical scientist :

The code in Excel is actually called GRG2 (the 2 does matter). Unlike any of the methods for optim(), it can handle nonlinear inequality constraints and does not need a feasible initial solution.

There's a blurb about it in the NEOS optimisation guide: http://www-fp.mcs.anl.gov/otc/Guide/SoftwareGuide/Blurbs/grg2.html

Judging from this blurb, it will be similar to L-BFGS-B for problems with no constraints or box constraints. -thomas

Thomas Lumley Assoc. Professor, Biostatistics tlumley at u.washington.edu University of Washington, Seattle

So under some conditions it may be suitable to use optim like this in place of the Excel solver:

optim(pars, 
      OptPars, 
      ... ,
      method = "L-BFGS-B")

Note that the NEOS optimisation guide is now here: http://neos-guide.org/content/optimization-guide and GRG2 is mentioned on this page: http://neos-guide.org/content/reduced-gradient-methods It lists BFGS, CONOPT and several others as related algorithms. The article describes these as 'projected augmented Lagrangian algorithm.' According to the Optimization CTV, these algorithms can be found in nloptr, alabama and Rsolnp.

I've had good matches (to six sig figs) between the Excel solver and R using the optimx package, but YMMV.

like image 3
Ben Avatar answered Nov 12 '22 17:11

Ben