From jh910 at juno.com  Sun Jul  6 20:59:03 2008
From: jh910 at juno.com (J. R. M. Hosking)
Date: Sun, 06 Jul 2008 14:59:03 -0400
Subject: [Rd] Editing the "..." argument
In-Reply-To: <486FB57D.6010801@epfl.ch>
References: <486FB57D.6010801@epfl.ch>
Message-ID: <g4r4lm$10a$1@ger.gmane.org>

Mathieu Ribatet wrote:
>    Dear all,
> 
> I'd like tweaking the ... arguments that one user can pass in my 
> function for fitting a model. More precisely, my objective function is 
> (really) problematic to optimize using the "optim" function. 
> Consequently, I'd like to add in the "control" argument of the latter 
> function a "ndeps = rep(something, #par)" and/or "parscale = something" 
> if the user has not specified it already.
> 
> Do you know a way to deal with this point?
> In advance, thanks.
> 
> Mathieu

Package lmom, recently added to CRAN, contains a function 'pelp' that
does exactly what you describe.  Relevant parts of its code:

   # Get the user-supplied arguments for the optimization functions
   dotargs <- list(...)

   # If user didn't supply a "control" argument, create one
   if (is.null(dotargs$control)) dotargs<-c(dotargs,list(control=list()))

   # If user didn't provide "ndeps" or "abstol" elements of the "control"
   # argument, set them to our own defaults
   if (is.null(dotargs$control$ndeps))
     dotargs$control <- c(dotargs$control,list(ndeps=rep(acc,nshape)))
   if (method!="L-BFGS-B" && is.null(dotargs$control$abstol))
     dotargs$control <- c(dotargs$control,abstol=acc^2)

   # Call the optimization function, optim()
   opt <- do.call(optim,c(list(par=start[shape.pos]),fn=critfn,
     method=method,dotargs))


J. R. M. Hosking



[Rd] Editing the "..." argument
J. R. M. Hosking