constant: Constant priors in 'brms'

View source: R/priors.R

constantR Documentation

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)

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).

Value

A named list with elements const and broadcast.

See Also

set_prior

Examples

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"))


paul-buerkner/brms documentation built on April 14, 2024, 5:39 p.m.