10

I have a complex objective function I am looking to optimize. The optimization problem takes a considerable time to optimize. Fortunately, I do have the gradient and the hessian of the function available.

Is there an optimization package in R that can take all three of these inputs? The class 'optim' does not accept the Hessian. I have scanned the CRAN task page for optimization and nothing pops.

For what it's worth, I am able to perform the optimization in MATLAB using 'fminunc' with the the 'GradObj' and 'Hessian' arguments.

Ram Ahluwalia
  • 1,092
  • 1
  • 10
  • 25
  • 1
    check the `trust` package (http://goo.gl/HHHN1). it accepts a function that computes the `objective`, `gradient` and `hessian`. and if i recall correctly, it uses the same algorithm used by `fminunc` – Ramnath Nov 11 '11 at 03:00

2 Answers2

11

I think the package trust which does trust region optimization will do the trick. From the documentation of trust, you see that

This function carries out a minimization or maximization of a function using a trust region algorithm... (it accepts) an R function that computes value, gradient, and Hessian of the function to be minimized or maximized and returns them as a list with components value, gradient, and hessian.

In fact, I think it uses the same algorithm used by fminunc.

By default fminunc chooses the large-scale algorithm if you supply the gradient in fun and set GradObj to 'on' using optimset. This algorithm is a subspace trust-region method and is based on the interior-reflective Newton method described in [2] and [3]. Each iteration involves the approximate solution of a large linear system using the method of preconditioned conjugate gradients (PCG). See Large Scale fminunc Algorithm, Trust-Region Methods for Nonlinear Minimization and Preconditioned Conjugate Gradient Method.

Nightfirecat
  • 11,432
  • 6
  • 35
  • 51
Ramnath
  • 54,439
  • 16
  • 125
  • 152
1

Both stats::nlm() and stats::nlminb() take analytical gradients and hessians. Note, however, that the former (nlm()) currently does not update the analytical gradient correctly but that this is fixed in the current development version of R (since R-devel, svn rev 72555).

Johan Larsson
  • 3,496
  • 18
  • 34