adiff {rjmcmc}R Documentation

Automatic Differentiation Using Madness

Description

A wrapper function to the functionality of the madness package. Converts a given x to a madness object and then applies func to it, returning the result and the Jacobian for the transformation func. adiff is used by the rjmcmcpost function.

Usage

adiff(func, x, ...)

Arguments

func

The function to be differentiated (usually user-defined).

x

The values at which to evaluate the function func.

...

Further arguments to be passed to func.

Value

A numeric vector or matrix containing the result of the function evaluation func(x, ...). The "gradient" attribute of this object contains the Jacobian matrix of the transformation func.

References

Pav, S. E. (2016) Madness: Automatic Differentiation of Multivariate Operations.

See Also

madness

Examples

x2x3 = function(x){
return(c(x^2, x^3))
}

y = adiff(x2x3, c(5,6))
attr(y, "gradient")


[Package rjmcmc version 0.4.5 Index]