nimble-dev / nimbleHMC

HMC and other derivative-based MCMC sampling algorithms for the nimble package
GNU General Public License v3.0
13 stars 1 forks source link

nimbleHMC

tests

DOI

Provides derivative-based MCMC sampling algorithms and convenence functions, for use in conjunction with the MCMC engine avaialble in the nimble package. Sampling algorithms include:

See the HMC section of the Nimble User Manual for more information and examples.

General package information about nimbleHMC, and the complete API for package functions are available on CRAN.

Additional information about the nimblepackage itself is available at the nimble website.

Installation and Package Requirements

Use of nimbleHMC requires installation of the core nimble package. Detailed instructions for installing nimble are available in the nimble package README.

nimbleHMC must be used with version 1.0.0 or higher of nimble, or the latest version available on CRAN. To check the version number of the currently installed version of nimble, use:

packageVersion("nimble")

The nimbleHMC package itself can be installed directly from CRAN, using:

install.packages("nimbleHMC")

Automatic Differentiation

nimbleHMC makes use of the automatic differentiation (AD) feature of nimble, which was released in nimble version 1.0.0. See Chapter 16: Automatic Derivatives of the Nimble User Manual for more information about the capabilities of the AD system, and how to use the AD system to calculate derivatives of functions written as nimble algorithms, as well as derivatives of model calculations.

For using HMC sampling on a model, derivative calculations need to be built into for the model object. This is accomplished using the buildDerivs = TRUE argument in the call to nimbleModel as:

nimbleModel(code, constants, data, inits, buildDerivs = TRUE)

For using HMC sampling on models that include user-defined distributions, you will need to include the argument buildDerivs = TRUE in the definition of your distribution, as:

dmy_distribution <- nimbleFunction(
    run = function(x = double(), param = double(), log = integer(0, default = 0)) {
        ...
    },
    buildDerivs = TRUE
)

Contributing and Support

Contributions to the nimbleHMC package should be submitted via pull request on GitHub. For additional guideliens on making contributions, please see the contributing guidelines for the nimble package.

Issues, feature requests, or bugs should be reported using GitHub issues, submitted to the nimbleHMC repository.

For additional support using nimble or nimbleHMC, please see the Nimble User Manual. Any additional questions can be submitted to the nimble-users Google group.