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]]
.
DerivLogf(f, parNames, preSimplify = T, ...)Deriv2Logf(f, parNames, preSimplify = T, ...)
function(y, theta, ...)
, where theta
is a list of parameters.
a vector of names or indices, the subset of parameters to use.
simplify the body of f
using functions from package Deriv.
other arguments passed to Deriv
from package Deriv.
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.
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
.
Deriv, Deriv
in package Deriv, buildf
, numDerivLogf
, fisherI
# NOT RUN {
## see examples for param
## mind the gain regarding runtime compared to numDeriv
# }
Run the code above in your browser using DataLab