[R] constrOptim doesn´t send arguments to optim!(?)

Ricardo Zorzetto Nicoliello Vencio rvencio at ime.usp.br
Wed Oct 29 17:41:21 CET 2003


Hi,

I think that there something wrong with the 'constrOptim' max/minimization
function because she doesn´t send extra arguments to 'optim' call.

Fact: When I use optim in a f(x,theta)-like function, everything goes ok.
But using constrOptim with the same function leads to error...

Proof: Make a small change in the 'Rosenbrock Banana function' (taken from
the Examples section of those help pages) adding extra (useless)
parameters:

fr <- function(x,extra1,extra2) {   ## Rosenbrock Banana function
    x1 <- x[1]
    x2 <- x[2]
    extra1*extra2*100 * (x2 - x1 * x1)^2 + (1 - x1)^2
}
grr <- function(x,extra1,extra2) { ## Gradient of 'fr'
    x1 <- x[1]
    x2 <- x[2]
    extra1*extra2*c(-400 * x1 * (x2 - x1 * x1) - 2 * (1 - x1),
       200 *      (x2 - x1 * x1))
}


now, call it:

optim(c(-1.2,1), fr, grr, extra1=c(1,2), extra2=c(3,4))

ok!

but now:

constrOptim(c(-1.2,0.9), fr, grr, ui=rbind(c(-1,0),c(0,-1)), ci=c(-1,-1),
extra1=c(1,2), extra2=c(3,4) )

return the error:

Error in f(theta) : Argument "extra1" is missing, with no default

But in 'constrOptim' help page says:

...: Other arguments passed to `optim'

And in 'optim' help page says:

...: Further arguments to be passed to `fn' and `gr'.


My guess is that when 'constrOptim' calls 'optim' she doen´t send the
extra arguments to correct evaluation of functions non-f(x)-like such as
f(x,theta)-like.

But whow I (we?) can fix it ? Any ideas ?




More information about the R-help mailing list