optim: problem with additional arguments (PR#493)
dirk@surfer.sbm.temple.edu writes:
The R function "optim" fails when a function requires additional arguments, if the option "hessian=T" is specified. I am using R Version 1.0.0 on Windows 98.
....
optim(c(-1.2,1), fra, grra, method = "BFGS",a=100) # this works optim(c(-1.2,1), fra, grra, method = "BFGS",hessian=T,a=100) # this doesn't
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.)
O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._