Kang.Changku@epamail.epa.gov
2004-Jan-05 20:45 UTC
[R] optim function : "BFGS" vs "L-BFGS-B"
Dear kind R-experts. Does anybody have an experience to use optim function? If yes, what is the main difference between two method "BFGS" vs "L-BFGS-B"? I used "BFGS" method and got what I wanted. But when I used "L-BFGS-B" the error message said that "L-BFGS-B needs finite values of fn". So that means "BFGS" method can handle even if fn function is infinite value? What I really want to know is that can I get the same result by using L-BFGS-B method? +++++++++++++++++++++++++++++++++++++++++++++++++++++ Changku Kang National Center for Environmental Assessment EPA (B211F) 919-541-1396 919-541-0245 (fax) Kang.Changku at epa.gov Graduate Student Department of Statistics, NCSU ckang2 at stat.ncsu.edu 919-513-2956 +++++++++++++++++++++++++++++++++++++++++++++++++++++
The help page for optim() says: Function 'fn' can return 'NA' or 'Inf' if the function cannot be evaluated at the supplied value, but the initial value must have a computable finite value of 'fn'. (Except for method '"L-BFGS-B"' where the values should always be finite.) -roger Kang.Changku at epamail.epa.gov wrote:> > > > Dear kind R-experts. > > Does anybody have an experience to use optim function? > If yes, what is the main difference between two method "BFGS" vs > "L-BFGS-B"? > I used "BFGS" method and got what I wanted. But when I used "L-BFGS-B" > the error message said that "L-BFGS-B needs finite values of fn". So > that means > "BFGS" method can handle even if fn function is infinite value? > > What I really want to know is that can I get the same result by using > L-BFGS-B method? > > +++++++++++++++++++++++++++++++++++++++++++++++++++++ > Changku Kang > National Center for Environmental Assessment > EPA (B211F) > 919-541-1396 > 919-541-0245 (fax) > Kang.Changku at epa.gov > > Graduate Student > Department of Statistics, NCSU > ckang2 at stat.ncsu.edu > 919-513-2956 > +++++++++++++++++++++++++++++++++++++++++++++++++++++ > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >
On Mon, 5 Jan 2004 Kang.Changku at epamail.epa.gov wrote:> > > > > Dear kind R-experts. > > Does anybody have an experience to use optim function? > If yes, what is the main difference between two method "BFGS" vs > "L-BFGS-B"? > I used "BFGS" method and got what I wanted. But when I used "L-BFGS-B" > the error message said that "L-BFGS-B needs finite values of fn". So > that means > "BFGS" method can handle even if fn function is infinite value?Yes. BFGS can handle a function that gives NA or infinite values at some points (though it requires a finite starting value). L-BFGS-B cannot.> What I really want to know is that can I get the same result by using > L-BFGS-B method?It will depend on your starting values. If your starting values are good enough then L-BFGS-B may not encounter any infinite or undefined points before reaching the optimum. You may also be able to use the box constraints in L-BFGS-B to restrict the algorithm to a portion of the parameter space where there aren't any infinite or undefined values. If you don't start close enough to the optimum or if the problem is badly conditioned enough, then neither algorithm might converge, or they might converge to different local optima, or one might converge and the other might not. There aren't a lot of guarantees in numerical optimisation. -thomas Thomas Lumley Assoc. Professor, Biostatistics tlumley at u.washington.edu University of Washington, Seattle
Kang.Changku@epamail.epa.gov
2004-Jan-05 22:42 UTC
[R] optim function : "BFGS" vs "L-BFGS-B"
Well, thanks for your quick response. In fact, I have another question. There is a function in Splus, "nlminb". I want to do the same things in R. According to help, nlminb function uses a quasi-Newton method and this minimization is subject to box constraint. So, in this sense I tried to use "BFGS" and "L-BFGS-B". But in both cases, I couldn't get same result. I'm not sure which method coincide with that of Splus or at least more similar. Any suggestions would be very welcome. +++++++++++++++++++++++++++++++++++++++++++++++++++++ Changku Kang National Center for Environmental Assessment EPA (B211F) 919-541-1396 919-541-0245 (fax) Kang.Changku at epa.gov Graduate Student Department of Statistics, NCSU ckang2 at stat.ncsu.edu 919-513-2956 +++++++++++++++++++++++++++++++++++++++++++++++++++++