Skip to content

Commit 382f80f

Browse files
committed
updated nimbleHMC to include userEnv argument
1 parent 85ecdbb commit 382f80f

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

nimbleHMC/DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
Package: nimbleHMC
22
Title: Hamiltonian Monte Carlo and Other Gradient-Based MCMC Sampling Algorithms for 'nimble'
3-
Version: 0.2.3
3+
Version: 0.2.4
44
Date: 2024-12-18
55
Authors@R: c(person("Daniel", "Turek", role = c("aut", "cre"), email = "danielturek@gmail.com"),
66
person("Perry", "de Valpine", role = "aut"),
77
person("Christopher", "Paciorek", role = "aut"))
88
Maintainer: Daniel Turek <danielturek@gmail.com>
99
Description: Provides gradient-based MCMC sampling algorithms for use with the MCMC engine provided by the 'nimble' package. This includes two versions of Hamiltonian Monte Carlo (HMC) No-U-Turn (NUTS) sampling, and (under development) Langevin samplers. The `NUTS_classic` sampler implements the original HMC-NUTS algorithm as described in Hoffman and Gelman (2014) <doi:10.48550/arXiv.1111.4246>. The `NUTS` sampler is a modern version of HMC-NUTS sampling matching the HMC sampler available in version 2.32.2 of Stan (Stan Development Team, 2023). In addition, convenience functions are provided for generating and modifying MCMC configuration objects which employ HMC sampling. Functionality of the 'nimbleHMC' package is described further in Turek, et al (2024) <doi: 10.21105/joss.06745>.
10-
Depends: R (>= 3.5.0), nimble (>= 1.0.0)
10+
Depends: R (>= 3.5.0), nimble (>= 1.4.0)
1111
Imports: methods
1212
Suggests: testthat
1313
License: BSD_3_clause + file LICENSE | GPL (>= 2)

nimbleHMC/R/HMC_configuration.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,11 +320,12 @@ nimbleHMC <- function(code,
320320
samples = TRUE,
321321
samplesAsCodaMCMC = FALSE,
322322
summary = FALSE,
323-
WAIC = FALSE) {
323+
WAIC = FALSE,
324+
userEnv = parent.frame()) {
324325
if(missing(code) && missing(model)) stop('must provide either code or model argument')
325326
if(!samples && !summary && !WAIC) stop('no output specified, use samples = TRUE, summary = TRUE, or WAIC = TRUE')
326327
if(!missing(code) && inherits(code, 'modelBaseClass')) model <- code ## let's handle it, if model object is provided as un-named first argument
327-
Rmodel <- mcmc_createModelObject(model, inits, nchains, setSeed, code, constants, data, dimensions, check, buildDerivs = TRUE)
328+
Rmodel <- mcmc_createModelObject(model, inits, nchains, setSeed, code, constants, data, dimensions, check, buildDerivs = TRUE, userEnv = userEnv)
328329
Rmcmc <- buildHMC(Rmodel, type = type, monitors = monitors, thin = thin, enableWAIC = WAIC, print = FALSE)
329330
compiledList <- compileNimble(Rmodel, Rmcmc) ## only one compileNimble() call
330331
Cmcmc <- compiledList$Rmcmc

0 commit comments

Comments
 (0)