Learn R Programming

brms (version 2.22.0)

constant: Constant priors in brms

Description

Function used to set up constant priors in brms. The function does not evaluate its arguments -- it exists purely to help set up the model.

Usage

constant(const, broadcast = TRUE)

Value

A named list with elements const and broadcast.

Arguments

const

Numeric value, vector, matrix of values to which the parameters should be fixed to. Can also be a valid Stan variable in the model.

broadcast

Should const be automatically broadcasted to the correct size of the parameter? Defaults to TRUE. If you supply vectors or matrices in const or vector/matrix valued Stan variables, you need to set broadcast to TRUE (see Examples).

See Also

set_prior

Examples

Run this code
stancode(count ~ Base + Age, data = epilepsy,
         prior = prior(constant(1), class = "b"))

# will fail parsing because brms will try to broadcast a vector into a vector
stancode(count ~ Base + Age, data = epilepsy,
         prior = prior(constant(alpha), class = "b"),
         stanvars = stanvar(c(1, 0), name = "alpha"))

stancode(count ~ Base + Age, data = epilepsy,
         prior = prior(constant(alpha, broadcast = FALSE), class = "b"),
         stanvars = stanvar(c(1, 0), name = "alpha"))

Run the code above in your browser using DataLab