Priors and Boundaries
Purpose
This page defines how DSAMbayes specifies, defaults, overrides, and scales coefficient priors and parameter boundaries for all model classes. It covers the prior schema, supported families, default-generation logic, YAML override contract, and the interaction between priors, boundaries, and the scale=TRUE pathway.
Prior schema
Each model object carries a .prior tibble with one row per parameter. The columns are:
| Column | Type | Meaning |
|---|---|---|
parameter |
character | Parameter name (matches design-matrix column or special name) |
description |
character | Human-readable label |
distribution |
call | R distribution call, e.g. normal(0, 5) |
is_default |
logical | Whether the row was generated by default_prior() |
Supported prior families
| Family | Stan encoding | Use case |
|---|---|---|
normal(mean, sd) |
Default (prior_family_noise_sd = 0) |
Coefficient priors (location–scale) |
lognormal_ms(mean, sd) |
Encoded as prior_family_noise_sd = 1 with log-transformed parameters |
noise_sd prior when positive-support is desired |
All coefficient priors use normal(). The lognormal_ms family is available only for the noise_sd parameter and is parameterised by the mean and standard deviation on the original (non-log) scale; DSAMbayes converts these internally to log-space parameters.
Default prior generation
BLM and hierarchical (population terms)
default_prior.blm() calls standard_prior_terms(), which produces normal(0, 5) for each population-formula term (intercept and slope terms) plus a noise_sd entry.
Hierarchical (group-level standard deviations)
default_prior.hierarchical() additionally generates sd_<idx>[<term>] rows for each group factor. The prior standard deviation is set to the between-group standard deviation of the response, rounded to two decimal places.
BLM from lm (Bayesian updating)
default_prior.bayes_lm_updater() initialises coefficient priors from the OLS point estimates (mean) and standard errors (sd), enabling informative Bayesian updating.
Pooled
default_prior.pooled() uses the BLM defaults for non-pooled terms (intercept, base regressors, noise_sd) and normal(0, 5) for each dimension-level pooled coefficient.
Boundary schema
Each model object carries a .boundaries tibble with one row per parameter:
| Column | Type | Meaning |
|---|---|---|
parameter |
character | Parameter name |
description |
character | Human-readable label |
boundary |
list-column | List with $lower and $upper (numeric scalars) |
is_default |
logical | Whether the row was generated by default_boundary() |
Default boundaries are lower = -Inf, upper = Inf for all terms. No sign constraints are imposed by default.
YAML override contract
Prior overrides
Each override replaces the distribution call for the named parameter with normal(mean, sd). Overrides are sparse: only the listed parameters are changed; all other parameters keep their defaults.
When use_defaults: false, the default prior table is not generated. This is not recommended for typical use.
Boundary overrides
Each override replaces the boundary entry for the named parameter. YAML infinity tokens (.Inf, -.Inf) are coerced during config resolution.
Scale semantics (scale = TRUE)
When model.scale: true (the default), the response and predictors are standardised before Stan fitting. This affects both priors and boundaries.
Coefficient prior scaling
Prior standard deviations are scaled by the ratio sx / sy for slope terms and by 1 / sy for the intercept. The noise_sd prior standard deviation is multiplied by sy (the response standard deviation) to remain interpretable in the scaled space.
Boundary scaling
- Zero boundaries (
0) are invariant under scaling. - Infinite boundaries (
±Inf) are invariant under scaling. - Finite non-zero boundaries for slope terms are scaled using
scale_boundary_for_parameter(), which applies the samesx / syratio used for slope priors. - If a finite non-zero boundary is specified for a parameter without a matching scale factor in the design matrix, DSAMbayes aborts with a validation error.
Practical implication
Users specify priors and boundaries on the original (unscaled) data scale. DSAMbayes converts them internally before passing data to Stan. Post-fit, coefficient draws are back-transformed to the original scale by get_posterior().
Interaction with model classes
| Behaviour | BLM | Hierarchical | Pooled |
|---|---|---|---|
| Default priors | normal(0, 5) per term |
Population: same as BLM; group SD: data-derived | Non-pooled: BLM defaults; pooled: normal(0, 5) per dimension |
| Boundary defaults | (-Inf, Inf) per term |
Same as BLM for population terms | Per-dimension boundaries for pooled terms |
| Prior scaling | sx / sy ratio |
Same, computed on pooled model frame | Same, computed on full model frame |
| Boundary scaling | Same ratio | Same | Same |
Programmatic API
Inspect priors and boundaries
Override priors
Override boundaries
Minimal-prior policy
The recommended operating profile for MMM is documented in Minimal-Prior Policy. The policy keeps priors weak by default and uses hard constraints only when there is structural business knowledge.
Cross-references
- Model Classes — constructor and fit support per class
- Minimal-Prior Policy — governance guidance for prior specification
- Response Scale Semantics — link vs KPI scale behaviour
- Config Schema — YAML prior and boundary keys