Version 1.3.0 of NIMBLE released

We’ve released the newest version of NIMBLE on CRAN and on our website. NIMBLE is a system for building and sharing analysis methods for statistical models, especially for hierarchical models and computationally-intensive methods (such as MCMC, Laplace approximation, and SMC).

Version 1.3.0 provides some new and improved functionality, plus some bug fixes and improved error trapping.

The new and improved functionality includes:

  • A new multivariate sampler, the Barker proposal sampler (sampler_barker). We encourage users to try this sampler in place of the block Metropolis RW_block sampler and let us know how well it works. The Barker sampler uses gradient information and may improve adaptation behavior, including
    better mixing when parameters are on different scales or the initialproposal scale is too large.
  • An improved Laplace/AGHQ implementation that includes use of the nlminb optimizer for both inner and outer optimization (for better optimization performance), improved messaging and output naming, returning the log-likelihood and degrees of freedom for model selection calculations, and unified control of optimization method and other controls at either the build stage or through the updateSettings method.
  • The addition of the BOBYQA optimization method through nimOptim, registered via nimOptimMethod.

In addition to the new and improved functionality above, other bug fixes, improved error trapping, and enhancements include:

  • Preventing the use of nimbleFunction method names and nimbleFunction names that conflict with names in the nimble language (DSL).
  • More carefully checking for and warning of cases of NaN and non-finite log probability values in various samplers that in some cases may indicate invalid MCMC sampling.
  • More carefully handling of NaN and non-finite log probability values in the CRP sampler.
  • Error trapping cases of dynamic indices producing a non-scalar result in AD-enabled models and provide a suggested work-around.
  • Error trapping use of a non-existent nimbleList.
  • Preventing use of a single seed when running multiple chains via runMCMC.
  • Improving messaging related to lack of derivative support for functions.
  • Adding information about model macros to the manual.
  • Fixing bug in caching values in the CRP sampler when maximum number of clusters is exceeded, which would have caused incorrect sampling (albeit with the user having been warned that they should increase the maximum number of clusters).
  • Fixing an issue preventing use of nimbleList elements in nimCat.
  • Preventing an adaptation interval of one for various block samplers for which an interval of one leads to an error.
  • Allowing runLaplace to use an uncompiled Laplace object.

Please see the release notes on our website for more details.

Version 1.2.0 of NIMBLE released

We’ve released the newest version of NIMBLE on CRAN and on our website. NIMBLE is a system for building and sharing analysis methods for statistical models, especially for hierarchical models and computationally-intensive methods (such as MCMC, Laplace approximation, and SMC).

This release provides provides extensive new functionality, including:

  • A Pólya-gamma sampler, `sampler_polyagamma`, for conjugate sampling of linear predictor parameters in logistic regression model specifications, including handling zero inflation and stochastic design matrices. This sampler must be added to an MCMC configuration manually.
  • A new sampler, `sampler_noncentered`, which samples the mean or standard deviation of a set of random effect values in a transformed space such that the random effects are deterministically shifted or scaled given new values of their hyperparameters. For random effects written in a centered parameterization, sampling is performed as if they had been written in a noncentered parameterization, thereby enabling a variant on the Yu and Meng (2011) interweaving sampling strategy of sampling in both parameterizations.This sampler must be added to an MCMC configuration manually.
  • Adaptive Gauss-Hermite quadrature (AGHQ) for integrating over continuous latent effects, as an extension of NIMBLE’s Laplace approximation functionality. We also add user-friendly R functions, `runLaplace` and `runAGHQ`, for using Laplace and AGHQ approximation for maximum likelihood estimation.
  • A more flexible optimization system via `nimOptim`, with support for `nlminb` built in as well as the capability for users to provide potentially arbitrary optimization functions in R.
  • Allowing the use of nimbleFunctions with setup code in models, either for user-defined functions via `<-` or for user-defined distributions via `~`. This supports holding large objects outside of model nodes for use in models.
  • A completely revamped MCEM algorithm, using automatic derivatives in the maximization when possible, fixing a bug so that any parts of the model not connected to the latent states are included in MLE calculations, giving greater control and adding minor extensions to the ascent-based MCEM approach, and converting `buildMCEM` to be a nimbleFunction rather than an R function.

In addition to the new functionality above, other enhancements and bug fixes include:

  • Improving the speed of MCMC and MCMC building in certain cases.
  • Adding an argument to buildMCMC controlling whether to initialize values in the model.
  • Providing the ability to control the number of digits printed in C++ output.
  • Allowing use of a categorical MCMC sampler with user-specified dcat-like distributions.
  • Warning of use of backward indexing in models.
  • Improve documentation of the LKJ distribution and of advanced aspects of writing code for derivative tracking using the AD system.
  • Fixing an insufficient check for conjugacy in stick-breaking specifications of Bayesian nonparametric distributions.
  • Fixing compilation failures occurring on Red Hat Linux.
  • Reenabling functionality for user-provided Eigen library and related updates to the autoconf configuration used in package building.
  • Enhancing functionality to support model macros, which will be fully released and documented in the future.
  • Removing deprecated `is.na.vec` and `is.nan.vec` functions.
  • Improving some warnings and error messages.

Please see the release notes on our website for more details.

Version 1.1.0 of NIMBLE released

We’ve released the newest version of NIMBLE on CRAN and on our website. NIMBLE is a system for building and sharing analysis methods for statistical models, especially for hierarchical models and computationally-intensive methods (such as MCMC,Laplace approximation, and SMC).

This release provides new functionality as well as various bug fixes and improved error trapping, including:

  • Improving our automatic differentiation (AD) system so it can be used in a wider range of  models, including models with stochastic indexing, discrete latent states, and CAR distributions. Support for AD for these models means that HMC sampling and Laplace approximation can be used.
  • Allowing distributions and functions (whether user-defined or built-in) that lack AD support (such as dinterval, dconstraint, and truncated distributions) to be used and compiled in AD-enabled models. The added flexibility increases the range of models in which one can use AD methods (HMC or Laplace) on some parts of a model and other samplers or methods on other parts.
  • Adding nimIntegrate to the NIMBLE language, providing one-dimensional numerical integration via adaptive quadrature, equivalent to R’s integrate. This can, for example, be used in a user-defined function or distribution for use in model code, such as to implement certain point process or survival models that involve a one-dimensional integral.
  • Adding a “prior samples” MCMC sampler, which uses an existing set of numerical samples to define the prior distribution of model node(s).
  • Better support of the dCRP distribution in non-standard model structures.
  • Adding error trapping to prevent accidental use of  C++ keywords as model variable names.
  • Removing the RW_multinomial MCMC sampler, which was found to generate incorrect posterior results (in cases when a latent state followed a multinomial distribution)
  • Fixing a bug in conjugacy checking in a case of subsets of multivariate nodes.
  • Fixing is.na and is.nan to operate in the expected vectorized fashion.
  • Improving documentation of AD, nimbleHMC, and nimbleSMC in the manual.
  • Updating Eigen (the C++ linear algebra library used by nimble) to version 3.4.0.

Please see the release notes on our website for more details.

nimbleHMC version 0.2.0 released, providing improved HMC performance

nimbleHMC provides Hamiltonian Monte Carlo samplers for use with NIMBLE, in particular NUTS samplers. NIMBLE’s HMC samplers can be flexibly assigned to a subset of model parameters, allowing users to consider various sampling configurations.

We’ve released version 0.2.0 of nimbleHMC, which includes a new default NUTS sampler inspired by Stan’s implementation of NUTS. It also provides an updated version of our previous NUTS sampler (which is based on the original Hoffman and Gelman paper, and is now called the ‘NUTS_classic’ sampler in NIMBLE) that fixes performance issues in version 0.1.1.

Version 1.0.1 of NIMBLE released, fixing a bug in version 1.0.0 affecting certain models

We’ve released the newest version of NIMBLE on CRAN and on our website. NIMBLE is a system for building and sharing analysis methods for statistical models, especially for hierarchical models and computationally-intensive methods (such as MCMC and SMC).
Version 1.0.1 follows shortly after 1.0.0 and fixes an issue and a bug introduced in version 1.0.0 causing data to be set incorrectly in certain models.
Both cases occur only when a variable (e.g., “x”) contains both stochastic nodes (e.g. “x[2] ~ <some distribution>”) and *either* deterministic nodes (e.g. “x[3] <- <some calculation>”) or right-hand-side-only nodes (e.g. “x[4]” appears only on the right-hand-side, like an explanatory value).
The issue involves a change of behavior (relative to previous nimble versions) when both setting data values for some nodes and initial values for other nodes within the same variable (that satisfies the previous condition). Data values for right-hand-side-only nodes were replaced by initial values (inits) if both were provided. Version 1.0.1 reverts to previous behavior that data values are not replaced by initial values in that situation.
The bug involves models where (for a variable satisfying the previous condition) not every scalar element within the variable is used as a node and some of the nodes in the variable are data. In that situation, data values may be set incorrectly. This could typically occur in models with autoregressive structure directly on some data nodes (such as may be the case for capture-recapture models involving many individual capture histories within the same variable, indexed by individual and time, with some individuals not present for the entire time series, resulting in unused scalar elements of the variable).
Please see the release notes on our website for more details.

Version 1.0.0 of NIMBLE released, providing automatic differentiation, Laplace approximation, and HMC sampling

We’ve released the newest version of NIMBLE on CRAN and on our website. NIMBLE is a system for building and sharing analysis methods for statistical models, especially for hierarchical models and computationally-intensive methods (such as MCMC and SMC).

Version 1.0.0 provides substantial new functionality. This includes:

  • A Laplace approximation algorithm that allows one to find the MLE for model parameters based on approximating the marginal likelihood in models with continuous random effects/latent process values.
  • A Hamiltonian Monte Carlo (HMC) MCMC sampler implementing the NUTS algorithm (available in the newly-released nimbleHMC package).
  • Support in NIMBLE’s algorithm programming system to obtain derivatives of functions and arbitrary calculations within models.
  • A parameter transformation system allowing algorithms to work in unconstrained parameter spaces when model parameters have constrained domains.

These are documented via the R help system and a new section at the end of our User Manual. We’re excited for users to try out the new features and let us know of their experiences. In particular, given these major additions to the NIMBLE system, we anticipate the possibility of minor glitches. The best place to reach out for support is still the nimble-users list.

In addition to the new functionality above, other enhancements and bug fixes include:

  • Fixing a bug (previously reported in a nimble-users message) giving incorrect results in NIMBLE’s cross-validation function (`runCrossValidate`) for all but the ‘predictive’ loss function for NIMBLE versions 0.10.0 – 0.13.2.
  • Fixing a bug in conjugacy checking causing incorrect identification of conjugate relationships in models with unusual uses of subsets, supersets, and slices of multivariate normal nodes.
  • Improving control of the `addSampler` method for MCMC.
  • Improving the WAIC system in a few small ways.
  • Enhancing error trapping and warning messages.

Please see the NEWS file in the package source for more details.

Version 0.13.0 of NIMBLE released

We’ve released the newest version of NIMBLE on CRAN and on our website. NIMBLE is a system for building and sharing analysis methods for statistical models, especially for hierarchical models and computationally-intensive methods (such as MCMC and SMC).
Version 0.13.0 provides new functionality (in particular improved handling of predictive nodes in MCMC) and minor bug fixes, including:

  • Thoroughly revamping handling of posterior predictive nodes in the MCMC system, in particular that MCMC samplers, by default, will now exclude predictive dependencies from internal sampler calculations. This should improve MCMC mixing for models with predictive nodes. Posterior predictive nodes are now sampled conditional on all other model nodes at the end of each MCMC iteration.
  • Adding functionality to the MCMC configuration system, including a new replaceSamplers method and updates to the arguments for the addSamplers method.
  • Adding an option to the WAIC system to allow additional burnin (in addition to standard MCMC burnin) before calculating online WAIC, thereby allowing inspection of initial samples without forcing them to be used for WAIC.
  • Warning users of unused constants during model building.
  • Fixing bugs that prevented use of variables starting with ‘logProb’ or named ‘i’ in model code.
  • Fixing a bug to prevent infinite recursion in particular cases in conjugacy checking.
  • Fixing a bug in simulating from dcar_normal nodes when multiple nodes passed to simulate.
Please see the release notes on our website for more details.

Keep everything organized in Ledger Live for Mac by tagging and taking notes so you can easily take note of your transactions and later refer to them.

NIMBLE virtual short course, January 4-6, 2023

We’ll be holding a virtual training workshop on NIMBLE, January 4-6, 2023 from 8 am to 1 pm US Pacific (California) time each day. NIMBLE is a system for building and sharing analysis methods for statistical models, especially for hierarchical models and computationally-intensive methods (such as MCMC and SMC).

Recently we added support for automatic differentiation (AD) to NIMBLE in a beta release, and the workshop will cover NIMBLE’s AD capabilities in detail.

The workshop will cover the following material:

  • the basic concepts and workflows for using NIMBLE and converting BUGS or JAGS models to work in NIMBLE.
  • overview of different MCMC sampling strategies and how to use them in NIMBLE, including Hamiltonian Monte Carlo (HMC).
  • writing new distributions and functions for more flexible modeling and more efficient computation.
  • tips and tricks for improving computational efficiency.
  • using advanced model components, including Bayesian non-parametric distributions (based on Dirichlet process priors), conditional auto-regressive (CAR) models for spatially correlated random fields, Laplace approximation, and reversible jump samplers for variable selection.
  • an introduction to programming new algorithms in NIMBLE.
  • use of automatic differentiation (AD) in algorithms.
  • calling R and compiled C++ code from compiled NIMBLE models or functions.

If you are interested in attending, please pre-register. Registration fees will be $125 (regular) or $50 (student).  We are also offering a process (see the pre-registration form) for students to request a fee waiver.

The workshop will assume attendees have a basic understanding of hierarchical/Bayesian models and MCMC, the BUGS (or JAGS) model language, and some familiarity with R.

Keep everything organized in Ledger Live for Mac by tagging and taking notes so you can easily take note of your transactions and later refer to them.

Beta version of NIMBLE with automatic differentiation, including HMC sampling and Laplace approximation

We’re excited to announce that NIMBLE now supports automatic differentiation (AD), also known as algorithmic differentiation, in a beta version available on our website. In this beta version, NIMBLE now provides:

  • Hamiltonian Monte Carlo (HMC) sampling for an entire parameter vector or arbitrary subsets of the parameter vector (i.e., combined with other samplers for the remaining parameters). 
  • Laplace approximation for approximate integration over latent states in a model, allowing maximum likelihood estimation and MCMC based on the marginal likelihood (via the RW_llFunction samplers).
  • The ability for users and algorithm developers to write nimbleFunctions that calculate derivatives of functions, including many but not all mathematical operations that are supported in the NIMBLE language.

We’re making this beta release available to allow our users to test and evaluate the AD functionality and the new algorithms, but it is not recommended for production use at this stage. So please give it a try, and let us know of any problems or suggestions you have, either via the nimble-users list, bug reports to our GitHub repository, or email to nimble.stats@gmail.com

You can download the beta version and view an extensive draft manual for the AD functionality.

We plan to release this functionality in the next NIMBLE release on CRAN in the coming months. 

Keep everything organized in Ledger Live for Mac by tagging and taking notes so you can easily take note of your transactions and later refer to them.

Version 0.12.2 of NIMBLE released, including an important bug fix for some models using Bayesian nonparametrics with the dCRP distribution

We’ve released the newest version of NIMBLE on CRAN and on our website. NIMBLE is a system for building and sharing analysis methods for statistical models, especially for hierarchical models and computationally-intensive methods (such as MCMC and SMC).

Version 0.12.2 is a bug fix release. In particular, this release fixes a bug in our Bayesian nonparametric distribution (BNP) functionality that gives incorrect MCMC results for some models, specifically when using the dCRP distribution when the parameters of the mixture components (i.e., the clusters) have hyperparameters (i.e., the base measure parameters) that are unknown and sampled during the MCMC. Here is an example basic model structure that is affected by the bug:

k[1:n] ~ dCRP(alpha, n)
for(i in 1:n) {
  y[i] ~ dnorm(mu[k[i]], 1)
  mu[i] ~ dnorm(mu0, 1) ## mixture component parameters with hyperparameter
}
mu0 ~ dnorm(0, 1) ## unknown cluster hyperparameter

(There is no problem without the hyperparameter layer – i.e., if mu0 is a fixed value – which is the situation in many models.)

We strongly encourage users using models with this type of structure to rerun their analyses, and we apologize for this issue.

Other changes in this release include:

  • Fixing an issue with reversible jump variable selection under a similar situation to the BNP issue discussed above (in particular where there are unknown hyperparameters of the regression coefficients being considered, which would likely be an unusual use case).
  • Fixing a bug preventing setup of conjugate samplers for dwishart or dinvwishart nodes when using dynamic indexing.
  • Fixing a bug preventing use of truncation bounds specified via `data` or `constants`.
  • Fixing a bug preventing MCMC sampling with the LKJ prior for 2×2 matrices.
  • Fixing a bug in `runCrossValidate` affecting extraction of multivariate nodes.
  • Fixing a bug producing incorrect subset assignment into logical vectors in nimbleFunction code.
  • Fixing a bug preventing use of `nimbleExternalCall` with a constant expression.
  • Fixing a bug preventing use of recursion in nimbleFunctions without setup code.

Please see the release notes on our website for more details.

 

Keep everything organized in Ledger Live for Mac by tagging and taking notes so you can easily take note of your transactions and later refer to them.