matchPrior {nimbleMacros}R Documentation

Match a prior from a list of prior settings

Description

Attempts to determine which prior to put on a parameter based on a list of settings, such as the output from setPriors(). The function follows the following search pattern: (1) looks for an exact match to the parameter name including brackets; (2) a match to the parameter name without brackets; (3) goes through each value supplied to ... in order and looks for a match in the names of the settings list. Once a match is found the function returns the corresponding prior value.

Usage

matchPrior(parName, ..., priors)

Arguments

parName

Parameter to get a prior for, as quoted code/name, possibly including brackets/indices

...

Character strings that categorize the parameter and match the names of elements in priors. The order is important: the first match found is used.

priors

A named list of prior settings, e.g., as generated by setPriors

Value

NIMBLE code for the matching prior.

Author(s)

Ken Kellner

Examples

pr <- setPriors(intercept = quote(dunif(-3, 3)), 'alpha' = quote(dunif(0,1)), 
                'alpha[2]' = "dnorm(0, 3)")
matchPrior(quote(alpha), priors=pr)
matchPrior(quote(alpha[2]), priors=pr)
matchPrior(quote(intercept), priors=pr)


[Package nimbleMacros version 0.1.1 Index]