Re: [Rd] names treatment in optim()

2015-10-08 Thread Christophe Dutang
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

[Rd] names treatment in optim()

2015-09-17 Thread Christophe Dutang
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