Learn R Programming

maxLik (version 1.5-2.1)

returnCode: Success or failure of the optimization

Description

These function extract success or failure information from optimization objects. The returnCode gives a numeric code, and returnMessage a brief description about the success or failure of the optimization, and point to the problems occured (see documentation for the corresponding functions).

Usage

returnCode(x, ...)
# S3 method for default
returnCode(x, ...)
# S3 method for maxLik
returnCode(x, ...)
returnMessage(x, ...)
# S3 method for maxim
returnMessage(x, ...)
# S3 method for maxLik
returnMessage(x, ...)

Value

Integer for returnCode, character for returnMessage. Different optimization routines may define it in a different way.

Arguments

x

object, usually an optimization result

...

further arguments for other methods

Author

Ott Toomet

Details

returnMessage and returnCode are a generic functions, with methods for various optimisation algorithms. The message should either describe the convergence (stopping condition), or the problem.

The known codes and the related messages are:

1

gradient close to zero (normal convergence).

2

successive function values within tolerance limit (normal convergence).

3

last step could not find higher value (probably not converged). This is related to line search step getting too small, usually because hitting the boundary of the parameter space. It may also be related to attempts to move to a wrong direction because of numerical errors. In some cases it can be helped by changing steptol.

4

iteration limit exceeded.

5

Infinite value.

6

Infinite gradient.

7

Infinite Hessian.

8

Successive function values withing relative tolerance limit (normal convergence).

9

(BFGS) Hessian approximation cannot be improved because of gradient did not change. May be related to numerical approximation problems or wrong analytic gradient.

10

Lost patience: the optimizer has hit an inferior value too many times (see maxSGA for more information)

100

Initial value out of range.

See Also

maxNR, maxBFGS

Examples

Run this code
## maximise the exponential bell
f1 <- function(x) exp(-x^2)
a <- maxNR(f1, start=2)
returnCode(a) # should be success (1 or 2)
returnMessage(a)
## Now try to maximise log() function
a <- maxNR(log, start=2)
returnCode(a) # should give a failure (4)
returnMessage(a)

Run the code above in your browser using DataLab