sns.fghEval.numaug {sns} | R Documentation |
Utility function for augmentation of a log-density function with numerical gradient and Hessian as needed
Description
Augmenting a log-density with numerical gradient and Hessian, so it can be used by sns
or sns.run
. This augmentation will also be done inside the function, if the value of numderiv
parameter passed to sns
and sns.run
is 1
or 2
. The advantage of using sns.fghEval.numaug
outside these functions is efficiency, since the agumentation code will not have to be executed in every function call. Users must set numderiv
to 0
when calling sns
or sns.run
if calling sns.fghEval.numaug
first. See example.
Usage
sns.fghEval.numaug(fghEval, numderiv = 0
, numderiv.method = c("Richardson", "simple")
, numderiv.args = list())
Arguments
fghEval |
Log-density to be sampled from. A valid log-density can have one of 3 forms: 1) return log-density, but no gradient or Hessian, 2) return a list of |
numderiv |
This must be matched with |
numderiv.method |
Method used for numeric differentiation. This is passed to the |
numderiv.args |
Arguments to the numeric differentiation method chosen in |
Value
A function, accepting same arguments as fghEval
, but guaranteed to return the original log-density, plus gradient and Hessian (both of which could possibly by numerically calculated). If numderiv=0
, fghEval
is returned without change. The function will return log-density, gradient and Hessian as elements f
, g
and h
of a list.
Note
See package vignette for more details on SNS theory, software, examples, and performance.
Author(s)
Alireza S. Mahani, Asad Hasan, Marshall Jiang, Mansour T.A. Sharabiani
References
Mahani A.S., Hasan A., Jiang M. & Sharabiani M.T.A. (2016). Stochastic Newton Sampler: The R Package sns. Journal of Statistical Software, Code Snippets, 74(2), 1-33. doi:10.18637/jss.v074.c02