
Last chance! 50% off unlimited learning
Sale ends in
Get a list of all parameter names (or certain categories of parameters) generated by model macros in the model code.
getMacroParameters(
model,
includeLHS = TRUE,
includeRHS = TRUE,
includeDeterm = TRUE,
includeStoch = TRUE,
includeIndexPars = FALSE
)
A named list of generated parameters, with the element names corresponding to the original source macro.
A NIMBLE model object
Include generated parameters on the left-hand side (LHS) of
assignments (<-
or ~
) in the output
Include generated parameters on the left-hand side (RHS) of
assignments (<-
or ~
) in the output
Include deterministic generated parameters in the output
Include stochastic generated parameters in the output
Include index parameters generated for use in for loops in the output
Some model macros will generate new parameters to be included in the output code. NIMBLE automatically detects these new parameters and records them in the model object. This function allows easy access to this stored list, or subsets of it (see arguments).
nimbleOptions(enableModelMacros = TRUE)
nimbleOptions(enableMacroComments = FALSE)
nimbleOptions(verbose = FALSE)
testMacro <- list(process = function(code, modelInfo, .env){
code <- quote({
for (i_ in 1:n){
mu[i_] <- alpha + beta
y[i_] ~ dnorm(0, sigma)
}
alpha ~ dnorm(0, 1)
})
list(code = code, modelInfo=modelInfo)
})
class(testMacro) <- "model_macro"
code <- nimbleCode({
y[1:n] ~ testMacro()
})
const <- list(y = rnorm(10), n = 10)
mod <- nimbleModel(code, constants=const)
mod$getMacroParameters()
# should be list(testMacro = list(c("mu", "alpha", "beta", "sigma")))
mod$getMacroParameters(includeRHS = FALSE)
# should be list(testMacro = list(c("mu", "alpha")))
Run the code above in your browser using DataLab