Learn R Programming

nlme (version 3.1-68.1)

fdHess: Finite difference Hessian

Description

Evaluate an approximate Hessian and gradient of a scalar function using finite differences.

Usage

fdHess(pars, fun, ..., .relStep=(.Machine$double.eps)^(1/3), minAbsPar=0)

Arguments

pars
the numeric values of the parameters at which to evaluate the function fun and its derivatives.
fun
a function depending on the parameters pars that returns a numeric scalar.
...
Optional additional arguments to fun
.relStep
The relative step size to use in the finite differences. It defaults to the cube root of .Machine$double.eps
minAbsPar
The minimum magnitude of a parameter value that is considered non-zero. It defaults to zero meaning that any non-zero value will be considered different from zero.

Value

  • A list with components
  • meanthe value of function fun evaluated at the parameter values pars
  • gradientan approximate gradient
  • Hessiana matrix whose upper triangle containst an approximate Hessian.

Details

This function uses a second-order response surface design known as a Koschal design to determine the parameter values at which the function is evaluated.

Examples

Run this code
fdHess(c(12.3, 2.34), function(x) x[1]*(1-exp(-0.4*x[2])))

Run the code above in your browser using DataLab