setPriors {nimbleMacros} | R Documentation |
Set up prior values for different categories of nodes
Description
Generates a list of custom specifications of priors for parameters in the model. It is possible to set priors for a category of parameters (e.g., intercept, coefficient, sd, factor, continuous) or to set a prior for a specific parameter name (optionally including brackets with indices).
Usage
setPriors(
intercept = quote(dnorm(0, sd = 1000)),
coefficient = quote(dnorm(0, sd = 1000)),
sd = quote(dunif(0, 100)),
factor = NULL,
continuous = NULL,
lkjShape = 1,
...
)
Arguments
intercept |
Prior specification for intercepts |
coefficient |
Prior specfication for slope coefficients |
sd |
Prior specification for random effects SDs |
factor |
Prior specifications for slope coefficients corresponding to factor data |
continuous |
Prior specifications for slope coefficients corresponding to continuous data |
lkjShape |
Value of shape parameter for LKJ distribution prior, used for correlation matrix in correlated random slope and intercept models |
... |
Specific parameters, optionally with brackets/indices |
Details
Exact name matches including brackets/indices are used first, followed by
name matches without indices, followed by data type (factor/continuous)
followed by parameter type (intercept/coefficient/sd).
Arguments can be supplied as quoted code, a character string, or
as a list of prior components. For example, to specify the prior
dnorm(0, sd = 10)
you could specify quote(dnorm(0, sd = 10))
,
or "dnorm(0, sd = 10)"
, or list("dnorm", 0, sd = 10)
.
Value
A named list of prior specifications to be passed to the priors
argument of other macros in the package, such as LINPRED
.
Author(s)
Ken Kellner
See Also
[nimble::dlkj_corr_cholesky] for more on the LKJ distribution
Examples
# Set a prior for intercept terms using quoted code
setPriors(intercept = quote(dunif(-5,5)))
# Instead using a character string
setPriors(intercept = "dunif(-5,5)")
# Set prior for slopes associated with factor covariates
setPriors(factor = quote(dnorm(0, sd = 2.5)))
# Set prior for a specific coefficient
setPriors('alpha[1]' = "dnorm(0, 3)")