HmcDualMod: Hamiltonian Monte Carlo with Dual Averaging and random...

Description Usage Arguments Value

Description

The function is modified version of Hamiltonian Monte Carlo with Dual Averaging. Based on the post by Radford Neal, Hamiltonian dynamics can be periodic for variables. It is possible for the period for a variabl to match its trajectory length, resulting the ending point close to the starting point. To address this issue, Neal proposes to randomly vary the trajectory length over some moderate range. Therefore, one modification is made: the previous code: Lm<-max(1,round(lambda/epsilon)) is changed to the new code: Lm<-max(1,round((0.9 + runif(1)/5)*lambda/epsilon))

Usage

1
HmcDualMod(theta0, delta, lambda, L, M, Madapt)

Arguments

theta0

a p-dimensional vector with the initial value for each parameter.

delta

the desired average acceptance probability

lambda

trajectory length for leapfrog

L

a callable function that returns a 2-dimensional vector whose first element is the logarithm of the density of the input and the second is the gradient of the logarithm of the density evaluated at the input.

M

an integer specifying the number of iterations.

Madapt

an integer specifying the number of iterations of the warmup phase.

Value

This function returns a matrix which m-th row is a sample from the joint density.


jodie0399/NUTS documentation built on May 29, 2019, 1:06 a.m.