[R] Using optim() with a function which returns more than a scalar - alternatives?

Søren Højsgaard Soren.Hojsgaard at agrsci.dk
Tue Feb 14 16:43:05 CET 2006


I want to numerically maximize a function with optim (maximization over several arguments). optim() needs a function which returns a scalar only. However, it could be nice to be able to "take other things out" from the function as well. I'tried to create an attribute to the scalar with what I want to take out, but that attribute disappears in optim(). I looked into the code to see if it could (easily) be modified such that it could work on a function which returns e.g. a list or a vector (and then it should be maximized over the first element). But I gave up... Any suggestion will be appreciated...
Best regards
Søren




More information about the R-help mailing list