[R] constrOptim and function with additional parameters?

From: Marlene Mueller <Marlene.Mueller_at_gmx.de>
Date: Wed 14 Jul 2004 - 22:59:01 EST

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:

> constrOptim(c(-1.2,0.9), fr, NULL, ui=rbind(c(-1,0),c(0,-1)),
ci=c(-1,-1),a=100)
Error in f(theta) : Argument "a" is missing, with no default

Is this a bug or is there a different solution that I miss here?

TIA, Marlene



R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed Jul 14 23:06:02 2004

This archive was generated by hypermail 2.1.8 : Fri 18 Mar 2005 - 02:36:05 EST