Source-linked AI summary
Advanced Bayesian Multilevel Modeling with the R Package brms
Paul-Christian Bürkner
TL;DR
Complex Bayesian multilevel regression requires flexible formulas and distributional or non-linear modeling options. The paper introduces brms’s extended lme4-like syntax and demonstrates it through examples, including distributional regression and correlated multilevel non-linear models. The examples show that these features support richer model specification, while the package remains subject to implementation and modeling-scope constraints.
Problem
Researchers need a unified way to specify complex Bayesian multilevel models involving multiple response parameters, non-linear relationships, and varied grouping structures.
Method
The paper introduces brms’s extended lme4-like formula syntax for distributional, non-linear, and multilevel regression models, illustrating it with examples.
Results
In the fish example, predicting zero-inflation probability from number of children improved model fit, although the improvement was modest and not substantial given its standard error.
Takeaways & Limitations
brms provides one framework for applying its extended formula syntax across the response distributions it supports, including complex multilevel models.
Takeaways & Limitations
The paper covers only a subset of brms modeling options, and extending brms with multivariate models and missing-value imputation remained planned future work.
Abstract
from arXiv · showhide
The brms package allows R users to easily specify a wide range of Bayesian single-level and multilevel models, which are fitted with the probabilistic programming language Stan behind the scenes. Several response distributions are supported, of which all parameters (e.g., location, scale, and shape) can be predicted at the same time thus allowing for distributional regression. Non-linear relationships may be specified using non-linear predictor terms or semi-parametric approaches such as splines or Gaussian processes. To make all of these modeling options possible in a multilevel framework, brms provides an intuitive and powerful formula syntax, which extends the well known formula syntax of lme4. The purpose of the present paper is to introduce this syntax in detail and to demonstrate its usefulness with four examples, each showing other relevant aspects of the syntax.
Model description
brms models responses by predicting every parameter of a response distribution, with each parameter receiving its own linked predictor. Its syntax also supports population- and group-level effects, smooth functions, and non-linear predictors.
- brms predicts all parameters θp of the response distribution D rather than only the response mean.
- Each distributional parameter θpi can use its own predictor ηpi transformed by an inverse link function fp.
- A general predictor combines population-level coefficients, group-level coefficients, and optional smooth functions of covariates.
- Smooth terms can be fitted with splines or Gaussian processes, while β, u, and the smooth functions are estimated as model parameters.
- brms also permits non-linear predictors whose user-defined functions depend on covariates and non-linear parameters with their own linear predictors.
Extended multilevel formula syntax
brms extends lme4 formulas to specify complex multilevel, distributional, and non-linear models. The extensions support multiple formulas, correlated group-level effects, alternative grouping structures, response information, and broad distributional coverage.
- Extended multilevel formula syntax: brms formulas apply across all supported response distributions, while users cannot easily define and run custom response distributions through Stan.
- Extended multilevel formula syntax: brms uses multiple formulas when complex models predict several parameters, and matching IDs correlate group-level terms across formulas sharing grouping factors.
- Extended multilevel formula syntax: The group syntax supports multiple grouping factors and special structures such as multi-membership through functions including gr and mm.
- Extended multilevel formula syntax: Non-linear models are specified with one formula for the model and additional formulas for each non-linear parameter, allowing grouped variation and correlated effects.
- Extended multilevel formula syntax: The first non-linear formula is taken literally, whereas formulas for non-linear parameters use standard brms-compatible parsing and can share correlated group-level effects.
- Extended multilevel formula syntax: Response-side addition terms can weight observations, provide known standard errors for meta-analysis, and represent censored or truncated data.
Examples
The examples demonstrate brms as a unified framework for distributional, non-linear, multilevel, and specialized regression models. Across applications, its syntax supports varied response distributions, smooth effects, group structure, model comparison, and uncertainty assessment.
- Unified framework: About 35 response distributions can be combined with brms formula syntax and its supported modeling extensions.The framework is intended to apply the same syntax across response distributions and multilevel regression models.
- Zero-inflated counts: The fish example uses a zero-inflated Poisson model to represent excess zeros and predicts the count from group size, children, and camper status.The model initially assumes a constant zero-inflation probability across observations.
- Zero-inflated counts: The fish model estimates a 41% mean zero-inflation probability, while including children in both model parts improves fit only modestly by LOO cross-validation.The model attributes more zero catches among groups with children to both lower counts and increased zero-inflation probability.
- Non-linear housing effects: Housing rents are highest for small, relatively new apartments, while rent variation is highest for relatively small, old apartments and smallest for medium to large apartments built around the 1960s.The combined predictor effect shows an interaction, and the scale spline models variation in rent per square meter.
- Insurance losses: The insurance-loss example models cumulative payments over development time with non-linear parameters, while showing accident-year variation and greater uncertainty for later years with fewer observations.A simpler model with only a varying intercept for ultimate loss is preferred because the data contain only 55 observations.
Conclusion
The paper introduces brms’s extended lme4 formula syntax for flexible regression modeling. It discusses only a subset of brms’s capabilities while identifying additional features planned for future implementation.
- The paper introduces R users and developers to brms’s extended lme4 formula syntax.
- The discussion covers only a subset of brms’s modeling options to keep the paper focused.
- Future planned features include extended multivariate models and missing value imputation.
- The planned feature set is expected to continue growing through incremental updates and user suggestions.