numDerivLogf: Build Derivative Function for Log f

Description Usage Arguments Details Value See Also Examples

Description

numDerivLogf/numDeriv2Logf 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
4
5
6
7
numDerivLogf(f, isLogf = FALSE, logZero = .Machine$double.xmin,
  logInf = .Machine$double.xmax/2, method = "Richardson",
  side = NULL, method.args = list())

numDeriv2Logf(f, isLogf = FALSE, logZero = .Machine$double.xmin,
  logInf = .Machine$double.xmax/2, method = "Richardson",
  method.args = list())

Arguments

f

function(y, theta, ...), where theta is a list of parameters. A joint probability density function.

isLogf

set to TRUE if f is already log(f).

logZero

the value log(f) should return if f evaluates to 0.

logInf

the value log(f) should return if f evaluates to Inf.

method, side, method.args

see grad and hessian in package numDeriv.

Details

numDeriv produces NaNs if the log evaluates to (negative) Inf so you may want to specify logZero and logInf.

numDerivLogf passes method, side and method.args directly to numDeriv::grad.

numDeriv2Logf duplicates the internals of numDeriv::hessian to gain speed. The defaults for method.args are list(eps=1e-4, d=0.1, zero.tol=sqrt(.Machine$double.eps/7e-7), r=4, v=2).

Value

numDerivLogf returns function(y, theta, i, ...) which evaluates to the first derivative of log(f(y, theta, ...)) with respect to theta[[i]].

numDeriv2Logf 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]].

See Also

grad and hessian in package numDeriv, buildf, DerivLogf, fisherI

Examples

1
## see examples for param

arappold/docopulae documentation built on May 10, 2019, 12:47 p.m.