From p.dalgaard@biostat.ku.dk  Fri Mar 17 18:43:42 2000
From: p.dalgaard@biostat.ku.dk (Peter Dalgaard BSA)
Date: 17 Mar 2000 19:43:42 +0100
Subject: [Rd] optim: problem with additional arguments (PR#493)
In-Reply-To: dirk@surfer.sbm.temple.edu's message of "Fri, 17 Mar 2000 18:02:48 +0100 (MET)"
References: <200003171702.SAA01912@pubhealth.ku.dk>
Message-ID: <x2zorxfndt.fsf@blueberry.kubism.ku.dk>

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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[Rd] optim: problem with additional arguments (PR#493)
Peter Dalgaard BSA