Function to calculate and return the gradient of the log posterior given a vector of values of theta
Minv
Inverse Mass matrix
constrain
Optional vector of which parameters in theta accept positive values only. Default is that all parameters accept all real numbers
lastSTEP
Boolean indicating whether to calculate the last half-step of the momentum update
...
Additional parameters passed to glogPOSTERIOR
Value
List containing two elements: theta.new the ending value of theta and r.new the ending value of the momentum
References
Neal, Radford. 2011. MCMC Using Hamiltonian Dynamics. In Handbook of Markov Chain Monte Carlo, edited by Steve Brooks, Andrew Gelman, Galin L. Jones, and Xiao-Li Meng, 116<U+2013>62. Chapman; Hall/CRC.
# NOT RUN {set.seed(321)
X <- cbind(1, rnorm(10))
y <- rnorm(10)
p <- runif(3) - 0.5leapfrog(rep(0,3), p, 0.01, g_linear_posterior,
diag(3), FALSE, X=X, y=y)
# }