bqmm fits Bayesian mixed-effects (multilevel) quantile regression models in R using the asymmetric Laplace working likelihood and Stan. It lets you ask how a predictor relates to any quantile of an outcome — the median, the tails, or a whole grid — while accounting for clustered or repeated-measures data through random effects, and it returns full Bayesian uncertainty.
The package fills a genuine gap in the R ecosystem. Existing tools
are either frequentist (lqmm, qrLMM), Bayesian
but single-level (bayesQR, Brq), or able to
fit multilevel quantile models only awkwardly and with statistically
invalid uncertainty (brms’s
asym_laplace()). bqmm provides a clean,
quantile-first interface and valid fixed-effect
inference via the Yang, Wang & He (2016) correction.
📖 Full documentation, primer, and articles: https://kvenkita.github.io/bqmm/
# install.packages("remotes")
remotes::install_github("kvenkita/bqmm")bqmm compiles Stan models on installation, so a working
C++ toolchain is required (Rtools on Windows, the standard compiler
chain on macOS/Linux).
library(bqmm)
data(Orthodont, package = "nlme")
# Conditional median of growth, with a random intercept per child
fit <- bqmm(distance ~ age + (1 | Subject), data = Orthodont, tau = 0.5)
summary(fit) # fixed effects with valid (adjusted) intervals
VarCorr(fit) # random-effect standard deviations
# Several quantiles in one call
fit_q <- bqmm(distance ~ age + (1 | Subject), data = Orthodont,
tau = c(0.1, 0.5, 0.9))
plot(fit_q) # coefficient-versus-quantile paths
predict(fit_q, noncrossing = "rearrange") # non-crossing quantileslme4 formula interface —
y ~ x + (1 + x | group); nested and crossed random
effects work out of the box.tau).cov = "unstructured" adds an LKJ-correlated random
intercept and slope, with the correlation reported by
VarCorr().posterior and bayesplot stacks via
as_draws(), and ships the usual
lme4/rstanarm-style methods.| Function | Purpose |
|---|---|
bqmm() |
Fit a Bayesian multilevel quantile regression model |
bqmm_prior() |
Specify priors (fixed effects, scale, random-effect SDs, LKJ) |
ald() |
The asymmetric Laplace family object |
summary(), fixef(),
coef() |
Fixed-effect estimates and intervals |
ranef(), VarCorr() |
Random effects and their (co)variances |
vcov(fit, adjusted = TRUE) |
Yang–Wang–He–corrected covariance |
predict(), fitted() |
Fitted / predicted conditional quantiles |
posterior_predict(),
posterior_epred() |
Posterior predictive draws |
as_draws() |
Hand the fit to posterior / bayesplot |
rearrange_quantiles() |
Remove quantile crossing |
If you use bqmm, please cite it:
Venkitasubramanian, K. (2026). bqmm: Bayesian Multilevel Quantile Regression. R package version 0.1.0. https://github.com/kvenkita/bqmm
citation("bqmm")Please also cite the underlying methodology where appropriate — Yu & Moyeed (2001) for the asymmetric Laplace approach and Yang, Wang & He (2016) for the inference correction.
Created and maintained by Kailas Venkitasubramanian. Released under the MIT License.