library(nimbleMacros)
<- nimbleCode({
code LM(weight[1:N] ~ Time + (1|Chick))
})
announcing the nimbleMacros package and the use of macros in NIMBLE models
Recent versions of NIMBLE now include the ability to use macros in models. 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).
A NIMBLE macro is a succinct syntax that expands to create the NIMBLE model code for part or all of a model.
We recently released the first version of the nimbleMacros
package on CRAN, which provides an initial set of macros available to users and developers. As an example, one could set up the code for a linear mixed effects model by using the LM
(“linear model”) macro like this:
with the formula syntax mimicking that of the lme4 package. After building the model based on the code
object, you can see the model code produced after the macro is expanded with model$getCode()
. The nimbleMacros package also includes macros for creating linear predictors and for loops, and we plan to add additional macros in the future.
Developers can use the tools in nimble
itself to create their own macros. See Section 12.4 of the NIMBLE user manual, the nimbleMacros
vignette, or help(buildMacro)
for more information.