Next: orthopoly() Up: Mathematical Macros Help File Previous: moorepenrose()   Contents

Usage:
 ```neldermead(fun, xstart, steps [,data] [, maxeval:maxeval, print:ip,\ stopcrit:eps, nloop:nloop, quad:F or T, simpcrit:s]), fun a macro, xstart and steps REAL vectors with no MISSING elements, data a variable as required by fun(), integers maxeval > 0, nloop > 0 and ip, REAL scalars eps > 0 and s > 0. fun() specifies a function to be minimized and is called as fun(x) or fun(x,data), where x is a REAL vector the same length as xstart. ```

Keywords: minimize, direct search
```neldermead() is a macro implementing function minimization by direct
search using the simplex method.  The minimum found may be a local,
not a global, minimum.  For details, see Nelder & Mead, The Computer
Journal, January 1965.

result <- neldermead(fun, xstart, steps) attempts to find a minimum of
the function F(x) computed by macro fun().

xstart, a REAL vector with no MISSING values, contains starting values
for x.

Macro fun() will be called as f <- fun(x, NULL) to evaluate
F(x), with argument 2 to be ignored.

steps is a REAL vector of non-negative numbers the same length as
xstart.  When steps[i] = 0, x[i] will remain fixed at xstart[i].  When
steps[i] > 0, it specifies an initial step size for building the
simplex.

result <- neldermead(fun, xstart, steps, data), where data is an
arbitrary variable, possibly a structure, does the same, except that
fun() will be called as f <- fun(x, data).  Argument data can contain
data or other constant information such as a fixed parameter.

except a quadratic approximation is fitted to F(x) near the minimum
found by searching and then the minimum of that approximation is
found.

The value returned has the form structure(x:xmin, f:minval,
invhessian:v, neval:n, status:s).

The components of the structure returned are as follows:
x:xmin        REAL vector contains the location of the minimum found
f:minval      REAL scalar = F(xmin), the minimum attained
invhessian:V  NULL or REAL square matrix describing the quadratic surface
neval:n       Integer > 0, the number of function evaluations required
status:s      Integer >= 0 specifying the termination status. s = 0
means successful termination at the apparent minimum; s
= 1 means termination because of excessive function
evaluations; s = 2 means v is not positive semidefinite
(only with quad:T), indicating stationary point is not a
minimum.

When F(x) = -log L(x), where x is a vector of parameters and L(x) is a
likelihood function, V is the inverse of the observed information matrix
and can be used as a variance-covariance matrix of the maximum
likelihood estimates.

When F(x) = sum((y - yhat(x))^2) is a sum of squared residuals, 2*MSE*V
is an estimate of the variance-covariance matrix of the least squares
estimates, where MSE = minval/edf, edf = error degrees of freedom.

maxeval:m   Integer m > 0, the maximum number of function evaluations
allowed; default is m = 1000
crit:eps    REAL scalar eps > 0.  Search will terminate when SD <= eps,
where SD = standard deviation of values of F(x) on a
simplex.  The default is eps = 1e-5
checkwhen:n Integer n > 0; the stopping rule is applied after every
n function evaluations. The default is n = 10.
simp:s      Small REAL scalar s > 0, a criterion for expanding the
final simplex to overcome rounding errors before fitting
1e-8.  See below for a guideline.
print:ip    Integer scalar ip controlling printing.  With ip < 0 (the
default), nothing will be printed unless an error is
found.  With ip = 0, the found minimum value and its
location will be printed as well as warning messages.
With ip > 0, the current value of x and F(x) will be
printed every ip function evaluations.  When ip >= 0
the returned structure is "invisible"; it can be
assigned but won't be printed automatically.

When the function minimized can be expected to be smooth in the vicinity
of the minimum, you are are strongly urged to use 'quad:T' to specify
the quadratic-surface fitting option.  This is the only satisfactory
way of testing that the minimum has been found.  When the fitted
quadratic surface is not positive definite (value of status = 2), it
probably means that the search terminated prematurely and you have not
found the minimum.

You should use simp:s, where s >= 10000 * E, where E = the rounding
error in calculating F(x). For example, the default simp:1e-8 is
appropriate when the rounding error in calculating F(x) may be of the
order of 1e-12.  If, say, the F(x) is computed by numerical integration
with accuracy on the order of 1e-05, simp:0.1 would be appropriate..

This advice is derived from the comments in the Fortran source on which

neldermead() is based on a Fortran program with the following history
Programmed by D.E.Shaw, CSIRO,  Division of Mathematics & Statistics
P.O. Box 218,  Lindfield,  N.S.W. 2070
With amendments by R.W.M.Wedderburn,Rothamsted Experimental Station,
Harpenden,  Hertfordshire,  England
Further amended by Alan Miller, CSIRO, Division of Mathematics &
Statistics, Private Bag 10,  Clayton,  Vic. 3168

For other macros to minimize functions, see minimizer(), bfs(), dfp()
and broyden().
```

Gary Oehlert 2003-01-15