/ Home
S-Archive Download Script
neldmead Nelder-Mead Simplex Algorithm
DESCRIPTION
Minimizes a, possibly non-smooth, user-supplied function using the Nelder-Mead Simplex Algorithm.
 
USAGE
neldmead(fobj, startvec, print.level=0, tol=1e-6, ...)
 
REQUIRED ARGUMENTS
fobj real-valued function.
startvec numeric vector of length 2 or greater. Initial value for the first argument of fobj.
 
OPTIONAL ARGUMENTS
print.level Desired level of output during the iteration. Print.level = 0 for quiet running, = 1 for function value at each iteration, = 2 to prompt for continuation after each iteration.
tol Desired accuracy.
... Additional arguments to be passed to fobj.
 
VALUE
List with the following components:
x numeric vector. Argument of fobj at the local minima.
fmin value of fobj at the local minima.
iter number of iterations used.
 
DETAILS
The Nelder-Mead simplex algorithm is an inefficient minimizer but it is not sensitive to starting values and does not rely on derivatives or even on continuity of the objective function. It is therefore useful for obtaining a decent starting point and scale information for one of the efficient methods, or for minimizing a non-smooth objective function which would not be suitable for the built-in S-Plus function nlmin.
 
The simplex method is applicable only to functions of several variables. If you want to minimize a continuous function of one variable, use the built-in S-Plus optimize instead.
 
AUTHOR
This function is a modified version of the functiontext.gif (93 bytes) posted by Bill Clark to the S-News news group in March 1997. David Clifford of the University of Chicago corrected and improved the implementation of the algorithm.
 
REFERENCES
Press et al, Numerical Methods in C, page 305.
 
SEE ALSO
nlmin and optimize in the S-Plus documentation.
EXAMPLES
# Find a least trimmed SS (LTS) regression estimator
# neldmead is more accurate but slower than the built-in
# S-Plus function ltsreg

> x <- 1:20
> y <- x + rnorm(20)
> lts <- function(ab, x, y)
{
	e <- y - ab[1] - ab[2] * x
	trim <- floor(length(y)/2) + floor(length(ab)/2)
	mean(sort(e^2)[1:trim])
}
> neldmead(lts,c(0,0),x=x,y=y)
$x:
[1] -0.09447435 1.00664786

$fmin:
[1] 0.04699288

$iter:
[1] 50
 
S-Archive Download Script

Gordon Smyth. Copyright © 1996-2016. Last modified: 10 February 2004