gBasicHMC(lpgrf, initial, nsims, nsteps, step,
burnin = 1, nstepsburnin = nsteps, stepburnin = step,
Tstart = 1, r = 1,
keep=keep, thin = 1, report = 100)
lpgrf
input must be a function which takes as its input a list of parameters and gives as its output the log probability (lp
) excluding the normalization constant and a first derivative of the log probability (gr
). Both the lp
and gr
information must be returned as slots in an object of class lpgr
. See details.
r
. The temperature is set to 1 if it drops below 1. Also, the temperature is set to 1 once the burnin phas is done.
keep = function(q) lapply(q, function(x) if(any(class(x) %in% c("gmatrix","gvector"))) g(x) else x)
.
thin=1
keeps all the samples. thin=5
keeps only ever fifth sample.
gBasicHMC()
is the lpgrf
parameter. This lpgrf
input must be a function which takes as its input a list of parameters and gives as its output the log probability (lp
) excluding the normalization constant and a first derivative of the log probability (gr
). Both the lp
and gr
information must be returned as slots in an object of class lpgrf
. The lp
slot must be a numberic CPU vector while gr
slot must be a list with elements either on the CPU or GPU.The function gBasicHMC()
is designed to run multiple chains simultaneously. Thus each element in the input is expected to be a matrix where the number of columns is the number of parallel chains and the number of rows is the dimension of the random variable being simulated. The input is assumed to be a list of parameters because in many cases there are different types of parameters such as hyper-parameters. Tracking the current stated of the chain using a list is therefore often quite natural. As a result of this convention, the gr
slot for lpgr
object returned by the lpgrf
function must also be a list.
Beam, Andrew L., Sujit K. Ghosh, and Jon Doyle. "Fast hamiltonian monte carlo using gpu computing." Journal of Computational and Graphical Statistics just-accepted (2015): 00-00.