search for: applydefault

Displaying 3 results from an estimated 3 matches for "applydefault".

Did you mean: applydefaults
2004 Jul 14
0
Re: [R] constrOptim and function with additional parameters? (PR#7088)
..., with no default >>> >>>Is this a bug or is there a different solution that I miss here? >> >> >> I can't spot why your use of constrOptim isn't working, but you should >> be able to workaround it by doing something like this: >> >> applyDefaults <- function(fn, ...) { >> function(x) fn(x, ...) >> } >> >> constrOptim(c(-1.2,0.9), applyDefaults(fr, a=100), NULL, >> ui=rbind(c(-1,0),c(0,-1)),ci=c(-1,-1)) >> >> The applyDefaults function creates a new function which evaluates the >> old o...
2004 Jul 14
0
Re: [R] constrOptim and function with additional parameters? (PR#7089)
...>> >>>>Is this a bug or is there a different solution that I miss here? >>> >>> >>>I can't spot why your use of constrOptim isn't working, but you should >>>be able to workaround it by doing something like this: >>> >>>applyDefaults <- function(fn, ...) { >>> function(x) fn(x, ...) >>>} >>> >>>constrOptim(c(-1.2,0.9), applyDefaults(fr, a=100), NULL, >>>ui=rbind(c(-1,0),c(0,-1)),ci=c(-1,-1)) >>> >>>The applyDefaults function creates a new function which evaluat...
2004 Jul 14
2
constrOptim and function with additional parameters?
How can I use a function with some additional input parameters in constrOptim? For example, something like fr <- function(x,a) { ## Rosenbrock Banana function x1 <- x[1] x2 <- x[2] a * (x2 - x1 * x1)^2 + (1 - x1)^2 } where the optimum is to be found w.r.t. x. Calling optim(c(-1.2,1), fr, NULL, a=100) works as expected, but I fail to provide the a=100 in the constrained case: