returnCode: Success or failure of the optimization

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/returnCode.R

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
returnCode(x, ...)
## Default S3 method:
returnCode(x, ...)
## S3 method for class 'maxLik'
returnCode(x, ...)
returnMessage(x, ...)
## S3 method for class 'maxim'
returnMessage(x, ...)
## S3 method for class 'maxLik'
returnMessage(x, ...)

Arguments

x

object, usually an optimization result

...

further arguments for other methods

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:

Value

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

Author(s)

Ott Toomet

See Also

maxNR, maxBFGS

Examples

1
2
3
4
5
6
7
8
9
## 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)

Example output

Loading required package: miscTools

Please cite the 'maxLik' package as:
Henningsen, Arne and Toomet, Ott (2011). maxLik: A package for maximum likelihood estimation in R. Computational Statistics 26(3), 443-458. DOI 10.1007/s00180-010-0217-1.

If you have questions, suggestions, or comments regarding the 'maxLik' package, please use a forum or 'tracker' at maxLik's R-Forge site:
https://r-forge.r-project.org/projects/maxlik/
[1] 1
[1] "gradient close to zero"
[1] 4
[1] "Iteration limit exceeded."

maxLik documentation built on July 27, 2021, 1:07 a.m.