lme4 (version 1.1-9)

NelderMead: Nelder-Mead Optimization of Parameters, Possibly (Box) Constrained

Description

Nelder-Mead optimization of parameters, allowing optimization subject to box constraints (contrary to the default, method = "Nelder-Mead", in R's optim()), and using reverse communications.

Usage

Nelder_Mead(fn, par, lower = rep.int(-Inf, n), upper = rep.int(Inf, n),
            control = list())

Arguments

fn
a function of a single numeric vector argument returning a numeric scalar.
par
numeric vector of starting values for the parameters.
lower
numeric vector of lower bounds (elements may be -Inf).
upper
numeric vector of upper bounds (elements may be Inf).
control
a named list of control settings. Possible settings are [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

Value

  • a list with components
  • fvalnumeric scalar - the minimum function value achieved
  • parnumeric vector - the value of x providing the minimum
  • convergenceinteger valued scalar, if not 0, an error code: [object Object],[object Object],[object Object],[object Object],[object Object]
  • messagea string specifying the kind of convergence.
  • controlthe list of control settings after substituting for defaults.
  • fevalthe number of function evaluations.

See Also

The NelderMead class definition and generator function.

Examples

Run this code
fr <- function(x) {   ## Rosenbrock Banana function
    x1 <- x[1]
    x2 <- x[2]
    100 * (x2 - x1 * x1)^2 + (1 - x1)^2
}
p0 <- c(-1.2, 1)

oo  <- optim(p0, fr) ## also uses Nelder-Mead by default
o.  <- Nelder_Mead(fr, p0)
o.1 <- Nelder_Mead(fr, p0, control=list(verbose=1))# -> some iteration output
stopifnot(identical(o.[1:4], o.1[1:4]),
          all.equal(o.$par, oo$par, tolerance=1e-3))# diff: 0.0003865
o.2 <- Nelder_Mead(fr, p0, control=list(verbose=3, XtolRel=1e-15, FtolAbs= 1e-14))
all.equal(o.2[-5],o.1[-5], tolerance=1e-15)# TRUE, unexpectedly

Run the code above in your browser using DataLab