nimble v0.7.0


Monthly downloads



MCMC, Particle Filtering, and Programmable Hierarchical Modeling

A system for writing hierarchical statistical models largely compatible with 'BUGS' and 'JAGS', writing nimbleFunctions to operate models and do basic R-style math, and compiling both models and nimbleFunctions via custom-generated C++. 'NIMBLE' includes default methods for MCMC, particle filtering, Monte Carlo Expectation Maximization, and some other tools. The nimbleFunction system makes it easy to do things like implement new MCMC samplers from R, customize the assignment of samplers to different parts of a model from R, and compile the new samplers automatically via C++ alongside the samplers 'NIMBLE' provides. 'NIMBLE' extends the 'BUGS'/'JAGS' language by making it extensible: New distributions and functions can be added, including as calls to external compiled code. Although most people think of MCMC as the main goal of the 'BUGS'/'JAGS' language for writing models, one can use 'NIMBLE' for writing arbitrary other kinds of model-generic algorithms as well. A full User Manual is available at <>.



One can specify the path to where the Eigen header files are located and also whether to link common C++ files into every DSO/DLL we create or whether to treat the files as an extra library with:

R CMD INSTALL --configure-args='--with-eigen=/home/duncan/local --enable-lib' nimble

or, within R

install.packages("nimble", configure.args = c("--with-eigen=/home/duncan/local", "--enable-lib=true"), repos = NULL)


Typically, you need the R developer tools (i.e., compiler, make, etc.) to use nimble. Accordingly, it is quite straightforward to install the package from source as you will have the necessary tools already installed. These are available from the Rtools page on CRAN.

To install the package from source, from within R,

install.packages("nimble", type = "source", INSTALL_opts = "--merge-multiarch")

or from a local copy of the source package,

install.packages("nimble_0.6-2.tar.gz", repos = NULL, INSTALL_opts = "--merge-multiarch")

Alternatively, use the shell command (in the DOS Command prompt)

R CMD INSTALL --merge-multiarch nimble_0.6-9.tar.gz

Of course, you can also compile directly from a clone of the git repository:

R CMD INSTALL --merge-multiarch nimble

The --merge-multiarch is necessary when using a version of R that supports both 32 and 64 bit. This option to installation will ensure that create both 32 and 64 bit installations.

Creating a Windows Binary

R CMD build nimble
R CMD INSTALL --build --merge-multiarch nimble_0.6-9.tar.gz

We need to create the .tar.gz file first, hence the first command.

Functions in nimble

Name Description
ADNimbleList EXPERIMENTAL Data type for the return value of nimDerivs
buildMCMC Create an MCMC function from a NIMBLE model, or an MCMC configuration object
carBounds Calculate bounds for the autocorrelation parameter of the dcar_proper distribution
CnimbleFunctionBase-class Class CnimbleFunctionBase
Constraint Constraint calculations in NIMBLE
declare Explicitly declare a variable in run-time code of a nimbleFunction
CAR-Normal The CAR-Normal Distribution
deregisterDistributions Remove user-supplied distributions from use in NIMBLE BUGS models
CAR-Proper The CAR-Proper Distribution
flat The Improper Uniform Distribution
Inverse-Gamma The Inverse Gamma Distribution
MCMCsuiteClass-class Class MCMCsuiteClass
ModifiedRmmParseKeywords2 [[' = 'outputCppArrayIndex2',
Inverse-Wishart The Inverse Wishart Distribution
as.carCM Convert weights vector to parameters of dcar_proper distributio
getBUGSexampleDir Get the directory path to one of the classic BUGS examples installed with NIMBLE package
make_MCMC_comparison_pages Make html pages summarizing results from compareMCMCs
asRow Turn a numeric vector into a single-row or single-column matrix
buildBootstrapFilter Create a bootstrap particle filter algorithm to estimate log-likelihood.
CAR_calcNumIslands Calculate number of islands based on a CAR adjacency matrix.
modelBaseClass-class Class modelBaseClass
ChineseRestaurantProcess The Chinese Restaurant Process Distribution
Categorical The Categorical Distribution
buildEnsembleKF Create an Ensemble Kalman filter algorithm to sample from latent states.
distributionInfo Get information about a distribution
Multinomial The Multinomial Distribution
Multivariate-t The Multivariate t Distribution
autoBlock Automated parameter blocking procedure for efficient MCMC sampling
buildAuxiliaryFilter Create an auxiliary particle filter algorithm to estimate log-likelihood. check if a nimbleFunction
configureMCMC Build the MCMCconf object for construction of an MCMC object
compileNimble compile NIMBLE models and nimbleFunctions
printErrors Print error messages after failed compilation
nimbleFunctionVirtual create a virtual nimbleFunction, a base class for other nimbleFunctions
nimbleList create a nimbleList check if a nimbleList
optimResultNimbleList EXPERIMENTAL Data type for the return value of nimOptim
model_macro_builder EXPERIMENTAL: Turn a function into a model macro builder A model macro expands one line of code in a nimbleModel into one or more new lines. This supports compact programming by defining re-usable modules. model_macro_builder takes as input a function that constructs new lines of model code from the original line of code. It returns a function suitable for internal use by nimbleModel that arranges arguments for input function. Macros are an experimental feature and are available only after setting nimbleOptions(enableModelMacros = TRUE).
reshape_comparison_results Convert comparison results to a more general format
getsize Returns number of rows of modelValues
identityMatrix Create an Identity matrix (Deprecated)
modelValuesBaseClass-class Class modelValuesBaseClass
eigenNimbleList eigenNimbleList definition
Interval Interval calculations
Exponential The Exponential Distribution
nfMethod access (call) a member function of a nimbleFunction
nimSvd Singular Value Decomposition of a Matrix
carMaxBound Calculate the upper bound for the autocorrelation parameter of the dcar_proper distribution
Wishart The Wishart Distribution
as.carAdjacency Convert CAR structural parameters to adjacency, weights, num format
resize Resizes a modelValues object
modelValuesConf Create the confs for a custom NIMBLE modelValues object
CmodelBaseClass-class Class CmodelBaseClass
sampler_BASE MCMC Sampling Algorithms
carMinBound Calculate the lower bound for the autocorrelation parameter of the dcar_proper distribution
MultivariateNormal The Multivariate Normal Distribution
nimDim return sizes of an object whether it is a vector, matrix or array
nimble nimble
nimble-R-functions NIMBLE language functions for R-like vector construction
combine_MCMC_comparison_results Combine multiple objects returned by compareMCMCs
nimEigen Spectral Decomposition of a Matrix
withNimbleOptions Temporarily set some NIMBLE options.
setAndCalculate Creates a nimbleFunction for setting the values of one or more model nodes, calculating the associated deterministic dependents and logProb values, and returning the total sum log-probability.
MCMCconf-class Class MCMCconf
Rmatrix2mvOneVar Set values of one variable of a modelValues object from an R matrix
nimble-internal Functions and Classes Internal to NIMBLE
MCMCsuite Executes multiple MCMC algorithms and organizes results.
nimbleCode Turn BUGS model code into an object for use in nimbleModel or readBUGSmodel
nimble-math Mathematical functions for BUGS and nimbleFunction programming
RmodelBaseClass-class Class RmodelBaseClass
buildLiuWestFilter Create a Liu and West particle filter algorithm.
checkInterrupt Check for interrupt (e.g. Ctrl-C) during nimbleFunction execution. Part of the NIMBLE language.
StickBreakingFunction The Stick Breaking Function
buildMCEM Builds an MCEM algorithm from a given NIMBLE model
compareMCMCs Run multiple MCMCs (packages or NIMBLE cases) for multiple models and return summary results
nimbleType-class create a nimbleType object
decide Makes the Metropolis-Hastings acceptance decision, based upon the input (log) Metropolis-Hastings ratio
getParam Get value of a parameter of a stochastic node in a model
nodeFunctions calculate, calculateDiff, simulate, or get the current log probabilities (densities) a set of nodes in a NIMBLE model
registerDistributions Add user-supplied distributions for use in NIMBLE BUGS models
decideAndJump Creates a nimbleFunction for executing the Metropolis-Hastings jumping decision, and updating values in the model, or in a carbon copy modelValues object, accordingly.
codeBlockClass-class Class codeBlockClass
getNimbleOption Get NIMBLE Option Determine if any values in a vector are NA or NaN
getLoadingNamespace return the namespace in which a nimbleFunction is being loaded
initializeModel Performs initialization of nimble model node values and log probabilities
getBound Get value of bound of a stochastic node in a model
getSamplesDPmeasure Get posterior samples for a Dirichlet process measure
getDefinition Get nimbleFunction definition
nimCopy Copying function for NIMBLE
nfVar Access or set a member variable of a nimbleFunction
makeBoundInfo Make an object of information about a model-bound pairing for getBound. Used internally
makeParamInfo Make an object of information about a model-parameter pairing for getParam. Used internally
nimCat cat function for use in nimbleFunctions
modelDefClass-class Class for NIMBLE model definition
nimDerivs Nimble Derivatives
modelValues Create a NIMBLE modelValues Object
nimMatrix Creates matrix or array objects for use in nimbleFunctions
nimPrint print function for use in nimbleFunctions
nimOptim Nimble wrapper around R's builtin optim.
rename_MCMC_comparison_method Rename a method in an object returned by compareMCMCs
testBUGSmodel Tests BUGS examples in the NIMBLE system
t The t Distribution
svdNimbleList svdNimbleList definition
nimNumeric Creates numeric, integer or logical vectors for use in nimbleFunctions
nimbleFunctionBase-class Class nimbleFunctionBase
nimbleFunctionList-class Create a list of nimbleFunctions
nimOptimDefaultControl Creates a deafult control argument for nimOptim.
updateMCMCcomparisonWithHighOrderESS Re-estimate effective sample size from results of compareMCMCs
optimControlNimbleList EXPERIMENTAL Data type for the control parameter of nimOptim
nimStop Halt execution of a nimbleFunction function method. Part of the NIMBLE language
optimDefaultControl Creates a deafult control argument for optim (just an empty list).
rankSample Generates a weighted sample (with replacement) of ranks
nimbleExternalCall Create a nimbleFunction that wraps a call to external compiled code
nimbleMCMC Executes one or more chains of NIMBLE's default MCMC algorithm, for a model specified using BUGS code
nimbleFunction create a nimbleFunction
nimbleModel Create a NIMBLE model from BUGS code
nimbleOptions NIMBLE Options Settings
nimbleRcall Make an R function callable from compiled nimbleFunctions (including nimbleModels).
runCrossValidate Perform k-fold cross-validation on a NIMBLE model fit by MCMC
run.time Time execution of NIMBLE code
runMCMC Run one or more chains of an MCMC algorithm and return samples, summary and/or WAIC
readBUGSmodel Create a NIMBLE BUGS model from a variety of input formats, including BUGS model files
simNodesMV Basic nimbleFunctions for using a NIMBLE model with sets of stored values
singleVarAccessClass-class Class singleVarAccessClass
samplerAssignmentRules-class Class samplerAssignmentRules
setAndCalculateOne Creates a nimbleFunction for setting the value of a scalar model node, calculating the associated deterministic dependents and logProb values, and returning the total sum log-probability.
setSize set the size of a numeric variable in NIMBLE
setupOutputs Explicitly declare objects created in setup code to be preserved and compiled as member data
simNodes Basic nimbleFunctions for calculate, simulate, and getLogProb with a set of nodes
valueInCompiledNimbleFunction get or set value of member data from a compiled nimbleFunction using a multi-interface
values Access or set values for a set of nodes in a model
Dirichlet The Dirichlet Distribution
Double-Exponential The Double Exponential (Laplace) Distribution
BUGSdeclClass-class BUGSdeclClass contains the information extracted from one BUGS declaration
No Results!

Last month downloads


Date 2019-01-31
SystemRequirements GNU make
License BSD_3_clause + file LICENSE | GPL (>= 2)
Copyright See COPYRIGHTS file.
Note For convenience, the package includes the necessary header files for the Eigen distribution. (This is all that is needed to use that functionality.) You can use an alternative installation of Eigen on your system or the one we provide. The license for the Eigen code is very permissive and allows us to distribute it with this package. See and also the License section on that page.
LazyData false
Collate config.R all_utils.R options.R distributions_inputList.R distributions_processInputList.R distributions_implementations.R BUGS_BUGSdecl.R BUGS_contexts.R BUGS_nimbleGraph.R BUGS_modelDef.R BUGS_model.R BUGS_graphNodeMaps.R BUGS_readBUGS.R BUGS_macros.R BUGS_testBUGS.R BUGS_getDependencies.R BUGS_utils.R BUGS_mathCompatibility.R externalCalls.R genCpp_exprClass.R genCpp_operatorLists.R genCpp_RparseTree2exprClasses.R genCpp_initSizes.R genCpp_buildIntermediates.R genCpp_processSpecificCalls.R genCpp_sizeProcessing.R genCpp_toEigenize.R genCpp_insertAssertions.R genCpp_maps.R genCpp_liftMaps.R genCpp_eigenization.R genCpp_TFize.R genCpp_addDebugMarks.R genCpp_generateCpp.R RCfunction_core.R RCfunction_compile.R nimbleFunction_util.R nimbleFunction_core.R nimbleFunction_nodeFunction.R nimbleFunction_nodeFunctionNew.R nimbleFunction_Rexecution.R nimbleFunction_compile.R nimbleFunction_keywordProcessing.R nimbleList_core.R types_util.R types_symbolTable.R types_modelValues.R types_modelValuesAccessor.R types_modelVariableAccessor.R types_nimbleFunctionList.R types_nodeFxnVector.R types_numericLists.R cppDefs_utils.R cppDefs_variables.R cppDefs_core.R cppDefs_namedObjects.R cppDefs_ADtools.R cppDefs_BUGSmodel.R cppDefs_RCfunction.R cppDefs_nimbleFunction.R cppDefs_nimbleList.R cppDefs_modelValues.R cppDefs_cppProject.R cppDefs_outputCppFromRparseTree.R cppInterfaces_utils.R cppInterfaces_models.R cppInterfaces_modelValues.R cppInterfaces_nimbleFunctions.R cppInterfaces_otherTypes.R nimbleProject.R initializeModel.R CAR.R MCMC_utils.R MCMC_configuration.R MCMC_build.R MCMC_run.R MCMC_samplers.R MCMC_conjugacy.R MCMC_suite.R MCMC_comparisons.R MCMC_autoBlock.R MCEM_build.R crossValidation.R filtering_resamplers.R filtering_auxiliary.R filtering_liuwest.R filtering_enkf.R filtering_bootstrap.R BNP_distributions.R BNP_samplers.R NF_utils.R miscFunctions.R makevars.R setNimbleInternalFunctions.R registration.R nimble-package.r zzz.R
RoxygenNote 5.0.1
NeedsCompilation yes
Packaged 2019-02-01 02:20:35 UTC; paciorek
Repository CRAN
Date/Publication 2019-02-01 15:20:03 UTC

Include our badge in your README