nimbleMacros

nimbleMacros is an R package that extends NIMBLE, an R package for hierarchical statistical modeling. The package provides a set of model macros, which are special code chunks that NIMBLE automatically expands into larger blocks of valid NIMBLE model code.

For example, the following NIMBLE model code contains a macro called LINPRED, and the objective is to create a linear predictor containing an intercept and a slope for one covariate, x.

code <- nimbleCode({
  mu[1:N] <- LINPRED(~x)
})

Given particular data and constants, NIMBLE will expand this macro into the following code:

{
  for (i_1 in 1:N){
    mu[i_1] <- beta_Intercept + beta_x * x[i_1]
  }
}

Provided macros include:

See the package vignette for more details.