Build Derivative Function for Log f

Description

DerivLogf/Deriv2Logf builds a function that evaluates to the first/second derivative of log(f(y, theta, ...)) with respect to theta[[i]]/theta[[i]] and theta[[j]].

Usage

1
2
3
DerivLogf(f, parNames, preSimplify = T, ...)

Deriv2Logf(f, parNames, preSimplify = T, ...)

Arguments

f

function(y, theta, ...), where theta is a list of parameters.

parNames

a vector of names or indices, the subset of parameters to use.

preSimplify

simplify the body of f using functions from package Deriv.

...

other arguments passed to Deriv from package Deriv.

Details

While numDerivLogf relies on the package numDeriv and therefore uses finite differences to evaluate the derivatives, DerivLogf utilizes the package Deriv to build sub functions for each parameter in parNames. The same is true for Deriv2Logf.

Value

DerivLogf returns function(y, theta, i, ...) which evaluates to the first derivative of log(f(y, theta, ...)) with respect to theta[[i]]. The attribute "d" contains the list of sub functions.

Deriv2Logf returns function(y, theta, i, j, ...) which evaluates to the second derivative of log(f(y, theta, ...)) with respect to theta[[i]] and theta[[j]]. The attribute "d2" contains the list of sub functions.

See Also

Deriv, Deriv in package Deriv, buildf, numDerivLogf, fisherI

Examples

1
2
## see examples for param
## mind the gain regarding runtime compared to numDeriv