On 05/07/2008 1:55 PM, 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.
It's generally not necessary to edit the ... args, but one way to do it
is like this:
dots <- list(...)
# do some editing
# instead of optim(a, b, ...), now you do
do.call(optim, c(list(a, b), dots))
In the particular example you gave, I wouldn't do this; I'd give control
as an arg to your function, and just edit that. For example,
myoptim <- function(control = list(), ...) {
if (is.null(control$ndeps)) control$ndeps <- rep(something, par)
if (is.null(control$parscale)) control$parscale <- something
optim(control=control, ...)
}
Duncan Murdoch
______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel