Add a new rule for assigning sampler(s) to the samplerAssignmentRules object. A rule consists of two parts: (1) a 'condition' which determines when the rule is invoked, and (2) a 'sampler' which governs the assignment of sampler(s) when the rule is invoked. New rules can be inserted at an arbitrary position in the ordered set of rules.
Arguments:
condition: The 'condition' argument must be a quoted R expression object, which will be evaluated and interpreted as a logical to control whether or not the rule is invoked. The condition will be evaluated in an environment which contains the BUGS 'model' object, the 'node' name to which the rules (and hence the sampler assignment process) are being applied, and other sampler assignment related arguments of configureMCMC() (e.g., 'useConjugacy' and 'multivariateNodesAsScalars'). Thus, the condition expression may involve these names, as well as methods of BUGS model objects. Creating an R expression object will generally use the function quote(...). For example: addRule(condition = quote(model$isBinary(node)), ...). Model-specific rules for particular nodes could be specified as: addRule(condition = quote(node == 'x' || node == 'y'), ...), or addRule(condition = quote(grepl('^sigma', node)), ...). Rules for specific distributions can be created as: addRule(condition = quote(model
sampler: The 'sampler' argument controls the sampler assignment process, once a rule is invoked (i.e., the 'condition' evaluated to TRUE). The 'sampler' argument must take one of three different forms: (1) a character string giving the name of an MCMC nimbleFunction sampler, (2) an unspecialized nimbleFunction object which is a valid MCMC sampler, or (3) an arbitrary quoted R expression object, which will be executed to perform the sampler assignment process, and should generally make use of the method addSampler(). Example (1): addRule(..., sampler = 'slice'), for assigning a 'slice' sampler when the rule is invoked. Example (2): addRule(..., sampler = my_sampler_nimbleFunction), for assigning the sampling algorithm defined in the object my_sampler_nimbleFunction. Note the same behaviour will result from: addRule(..., sampler = 'my_sampler_nimbleFunction'), which will be also more informative when the list of assignment rules is printed. Example (3): addRule(..., sampler = quote(
position: Index of the position to add the new rule. By default, new rules are added at the end of the current ordered set of rules (giving it the lowest priority in the sampler assignment process). Specifying a position inserts the new rule at that position, and does not over-write an existing rule.
name: Optional character string name for the sampler to be added, which is used by subsequent print methods. If 'name' is not provided, the 'sampler' argument is used to generate the name. Note, if the 'sampler' argument is provided as an R expression making use of the addSampler method, then the 'name' argument will not be passed on to the MCMC configuration object, and instead any call(s) to addSampler can explicitly make use of its own 'name' argument.
print: Logical argument (default = FALSE). If TRUE, the newly-added sampler assignment rule is printed.