Dear list,
A possible patch to correct the treatment of names consists in adding the
following lines
if(!is.null(names(par))) names(res$par) <- names(par)
if(!is.null(names(fn1(par names(res$value) <- names(fn1(par))
just before returning the variable res in optim. That is
opt
Dear both,
I have found that names are not treated in the same way in optim() depending on
the optimization method (argument method).
The example below shows the difference between the Brent method and the
L-BFGS-B method.
f <- function(x){ y <- x^2;names(y) <-"f(x)";y}
optim(10, f, method="B