gradient: Approximation of gradient vector.

Description Usage Arguments Details Value Examples

View source: R/auxiliar_functions.r

Description

gradient uses forward difference to approximate the vector of derivatives of fun at param.

Usage

1
  gradient(fun, param, ..., fun0 = NULL)

Arguments

fun

Function whose gradient vector is to be approximated.

param

Numeric vector of parameters where fun is to be evaluated

...

Any additional arguments passed to fun.

fun0

The value of fun at param. If it is NULL, fun will be evaluated at param.

Details

The forward difference uses a step-size of the cubic root of machine epsilon. No scaling is applied to parameters.

Value

A numeric row matrix whose size is determined by the length of param.

Examples

1
2
3
4
f  <- function(x) sum(x^2)
x0 <- c(1,1)
f0 <- f(x0)
gradient(f, x0, fun0 = f0)

nando11235813/raschreg documentation built on Oct. 2, 2021, 3:11 p.m.