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]]
.
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())
function(y, theta, ...)
, where theta
is a list of parameters.
A joint probability density function.
set to TRUE
if f
is already log(f)
.
the value log(f)
should return if f
evaluates to 0
.
the value log(f)
should return if f
evaluates to Inf
.
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]]
.
numDeriv produces NaN
s 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)
.
grad
and hessian
in package numDeriv, buildf
, DerivLogf
, fisherI
# NOT RUN {
## see examples for param
# }
Run the code above in your browser using DataLab