Skip to content
Prev 3516 / 63424 Next

optim: problem with additional arguments (PR#493)

dirk@surfer.sbm.temple.edu writes:
....
Yes. However, you can easily fix it for yourself. In optim(), the line

    hess <- .Internal(optimhess(res$par, fn, gr, con))

needs to be modified along the lines of

    res <- .Internal(optim(par, function(par) fn(par, ...),
                           function(par) gr(par, ...),
                           method, con, lower, upper))

(although that might get you in trouble if gr is NULL, so a permanent
fix would be slightly different.)