r-bayes

Fit brms multilevel Bayesian models with DAG-based causal assumption checks.

1|Updated May 13, 2026
One-click install
npx skills add https://github.com/impact-initiatives/ana_app --skill r-bayes-impact-initiatives
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: r-bayes
Source: https://github.com/impact-initiatives/ana_app/tree/main/.claude/.claude/skills/r-bayes
Command: npx skills add https://github.com/impact-initiatives/ana_app --skill r-bayes-impact-initiatives

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires brms, cmdstanr, dagitty, ggdag, marginaleffects, tidybayes, bayesplot.

What problem does it solve?

Bayesian analysis often becomes error-prone when models are built without a defensible causal structure, explicit priors, and rigorous diagnostics. This Skill helps you specify and validate causal assumptions with DAGs and then fit multilevel Bayesian models in R using brms, producing interpretable uncertainty-aware results.

Core Features & Use Cases

  • Causal DAG specification and validation: Build a directed acyclic graph in dagitty, validate implied conditional independencies against data, and visualize the DAG for stakeholder communication.
  • Bayesian regression with brms: Fit common model families (binary, counts, continuous, ordinal) with multilevel (random intercepts/slopes) structures and explicit priors.
  • Uncertainty-aware interpretation: Extract posterior draws, compute posterior probabilities of direction, and derive marginal effects and predictions with marginaleffects.
  • Model diagnostics and posterior checks: Assess MCMC convergence (R-hat, ESS), run posterior predictive checks, and compare prior vs posterior.

Quick Start

Fit a brms multilevel model for a binary outcome using a DAG-informed adjustment strategy, then compute marginal effects to interpret how predictors change P(outcome) with uncertainty.

Frequently Asked Questions about r-bayes

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I combine causal DAGs with Bayesian multilevel modeling in R?

You can specify and validate causal assumptions using dagitty and ggdag, then fit multilevel Bayesian regression models in R with brms to produce uncertainty-aware estimates based on your DAG-informed adjustment strategy.

What is the best way to compute marginal effects from brms posterior draws?

Use marginaleffects and tidybayes to extract posterior draws from brms models and compute marginal effects, allowing you to interpret how predictors change the outcome probability with full uncertainty intervals.

How do I check MCMC convergence and run posterior predictive checks in brms?

Assess MCMC convergence by examining R-hat and effective sample size (ESS) metrics, run posterior predictive checks, and compare prior versus posterior distributions using bayesplot and brms built-in diagnostic functions.

Can I fit Bayesian models for binary, count, and ordinal outcomes with random slopes?

Yes, brms supports fitting common model families including binary, count, continuous, and ordinal outcomes, and allows specifying multilevel structures with random intercepts and slopes alongside explicit priors.

Do I need cmdstanr to run brms Bayesian inference workflows?

Yes, cmdstanr serves as the backend engine for brms to compile and execute Stan models, enabling efficient MCMC sampling required for fitting Bayesian regression and extracting posterior distributions.

Why should I validate conditional independencies before fitting a Bayesian regression?

Validating implied conditional independencies against your data ensures your causal DAG is defensible before modeling, preventing error-prone Bayesian inference that stems from incorrect causal structures or missing confounders.