NUTS: No-U-Turn sampler

Description Usage Arguments Value

View source: R/nuts.R

Description

No-U-Turn sampler

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
NUTS(
  theta,
  f,
  grad_f,
  n_iter,
  M = diag(length(theta)),
  M_adapt = 50,
  M_chol = Matrix::chol(M),
  M_inv = Matrix::solve(M),
  delta = 0.5,
  max_treedepth = 10,
  eps = 1,
  find = TRUE,
  verbose = TRUE
)

Arguments

theta

Initial value for the parameters

f

log-likelihood function (up to a constant)

grad_f

the gradient of the log-likelihood function

n_iter

Number of MCMC iterations

M

the HMC mass matrix. Defaults to diag(length(theta)).

M_adapt

Parameter M_adapt in algorithm 6 in the NUTS paper

M_chol

The cholesky decomposition of M. Default Matrix::chol(M).

M_inv

The inverse of M. Default Matrix::solve(M).

delta

Target acceptance ratio, defaults to 0.5

max_treedepth

Maximum depth of the binary trees constructed by NUTS

eps

Starting guess for epsilon

find

Allow NUTS to make a better guess at epsilon? Default TRUE.

verbose

logical. Message diagnostic info each iteration? Default TRUE.

Value

Matrix with the trace of sampled parameters. Each mcmc iteration in rows and parameters in columns.


deepfriar/NUTS-mirror documentation built on Dec. 19, 2021, 10:08 p.m.