log(f)
with respect to a predefined set of variables/variable combinations.DerivLogf(f, names, map = NULL, yMap = NULL, thetaMap = NULL)Deriv2Logf(f, names, map = NULL, yMap = NULL, thetaMap = NULL)
a="b"
=> a <- b
).map
with a=b
resolving to a <- y[b]
.map
with a=b
resolving to a <- theta[[b]]
.DerivLogf
returns function(y, theta, i, ...)
where theta
is a list of parameters.
It evaluates to the first derivative of log(f)
with respect to variable i
.
Additionally the attribute "d"
contains the list of sub functions.Deriv2Logf
returns function(y, theta, i, j, ...)
where theta
is a list of parameters.
It evaluates to the second derivative of log(f)
with respect to the variables i
and j
.
Additionally the attribute "d2"
contains the list of sub functions.
numDerivLogf
relies on DerivLogf
utilizes Deriv
to build sub functions for each variable in names
.
The same is true for Deriv2Logf
.Deriv
won't recognize components or parameters accessed by [
, [[
or $
as variables (e.g. theta[["beta1"]]
).
Therefore it's necessary to specify mappings from y
and theta
to the variables in f
.
Deriv
in package buildf
, numDerivLogf
, fisherI
## see examples for param
## mind the gain regarding runtime compared to numDeriv
Run the code above in your browser using DataLab