Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

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.

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.

Value

A list with components

mean

the value of function fun evaluated at the parameter values pars

gradient

an approximate gradient (of length length(pars)).

Hessian

a matrix whose upper triangle contains an approximate Hessian.

Author(s)

José Pinheiro and Douglas Bates bates@stat.wisc.edu

Examples

(fdH <- fdHess(c(12.3, 2.34), function(x) x[1]*(1-exp(-0.4*x[2]))))
stopifnot(length(fdH$ mean) == 1,
          length(fdH$ gradient) == 2,
          identical(dim(fdH$ Hessian), c(2L, 2L)))

nlme

Linear and Nonlinear Mixed Effects Models

v3.1-152
GPL (>= 2) | file LICENCE
Authors
José Pinheiro [aut] (S version), Douglas Bates [aut] (up to 2007), Saikat DebRoy [ctb] (up to 2002), Deepayan Sarkar [ctb] (up to 2005), EISPACK authors [ctb] (src/rs.f), Siem Heisterkamp [ctb] (Author fixed sigma), Bert Van Willigen [ctb] (Programmer fixed sigma), Johannes Ranke [ctb] (varConstProp()), R-core [aut, cre]
Initial release
2021-02-03

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.