This is a wrapper around sns
, allowing one to draw multiple samples from a distribution while collecting diagnostic information.
sns.run(init, fghEval, niter = 100, nnr = min(10, round(niter/4))
, mh.diag = FALSE, part = NULL, print.level = 0
, report.progress = ceiling(niter/10)
, numderiv = 0, numderiv.method = c("Richardson", "simple")
, numderiv.args = list()
, ...)
sns.run
returns an object of class sns
with elements:
A matrix object with nsample
rows and K
cols.
Metropolis proposal percentage acceptance.
Number of burn-in ierations.
Time in seconds spent in sampling.
Time in seconds spent in burn-in.
Initial value for the MCMC chain.
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 f
and g
for log-density and its gradient vector, respectively, 3) return a list of f
, g
, and h
for log-density, gradient vector, and Hessian matrix. Missing derivatives are computed numerically.
Number of iterations to perform (in `nr' and `mcmc' mode combined).
Number of initial iterations to spend in `nr' mode.
Boolean flag, indicating whether detailed MH diagnostics such as components of acceptance test must be returned or not.
List describing partitioning of state space into subsets. Each element of the list must be an integer vector containing a set of indexes (between 1
and length(x)
or length(init)
) indicating which subset of all dimensions to jointly sample. These integer vectors must be mutually exclusive and collectively exhaustive, i.e. cover the entire state space and have no duplicates, in order for the partitioning to represent a valid Gibbs sampling approach. See sns.make.part
and sns.check.part
.
If greater than 0, print sampling progress report.
Number of sampling iterations to wait before printing progress reports.
Integer with value from the set 0,1,2
. If 0
, no numerical differentiation is performed, and thus fghEval
is expected to supply f
, g
and h
. If 1
, we expect fghEval
to provide f
amd g
, and Hessian will be calculated numerically. If 2
, fghEval
only returns log-density, and numerical differentiation is needed to calculate gradient and Hessian.
Method used for numeric differentiation. This is passed to the grad
and hessian
functions in numDeriv package. See the package documentation for details.
Arguments to the numeric differentiation method chosen in numderiv.method
, passed to grad
and hessian
functions in numDeriv. See package documentation for details.
Other parameters to be passed to fghEval
.
Alireza S. Mahani, Asad Hasan, Marshall Jiang, Mansour T.A. Sharabiani
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
sns
, summary.sns
, plot.sns
, predict.sns