Dear NIMBLE users,
Recent versions of NIMBLE now include the ability to use macros in models. 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, 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:
```
library(nimbleMacros)
code <- nimbleCode({
LM(weight[1:N] ~ Time + (1|Chick))
})
```
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.