Learn R Programming

optextras (version 2013-10.27)

grchk: Run tests, where possible, on user objective function and (optionally) gradient and hessian

Description

grchk checks a user-provided R function, ffn.

Usage

grchk(xpar, ffn, ggr, trace=0, testtol=(.Machine$double.eps)^(1/3), ...)

Arguments

xpar
parameters to the user objective and gradient functions ffn and ggr
ffn
User-supplied objective function
ggr
User-supplied gradient function
trace
set >0 to provide output from grchk to the console, 0 otherwise
testtol
tolerance for equality tests
...
optional arguments passed to the objective function.

Value

  • grchk returns a single object gradOK which is true if the differences between analytic and approximated gradient are small as measured by the tolerance testtol.

    This has attributes "ga" and "gn" for the analytic and numerically approximated gradients.

    At the time of preparation, there are no checks for validity of the gradient code in ggr as in the function fnchk.

Details

ll{ Package: grchk Depends: R (>= 2.6.1) License: GPL Version 2. } numDeriv is used to numerically approximate the gradient of function ffn and compare this to the result of function ggr.

Examples

Run this code
# Want examples of success and failure. What about "near misses"??

Run the code above in your browser using DataLab