pymc-bayesian-modeling
Bayesian modeling with PyMC 5: priors, likelihood, NUTS/ADVI sampling, diagnostics (R-hat, ESS), LOO/WAIC comparison, prediction. Hierarchical, logistic, GP variants; predictive checks.
npx skills add BioTender-max/awesome-bio-agent-skills --skill pymc-bayesian-modeling --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
What it does
This skill instructs the agent to implement Bayesian modeling workflows using PyMC 5, including defining priors, likelihoods, and a linear predictor; performing MCMC sampling with NUTS and optional ADVI; running prior predictive checks; diagnosing convergence with R-hat, ESS, and divergences; conducting posterior predictive checks; comparing models with LOO/WAIC; and generating posterior predictions for new data. It also includes common recipes for hierarchical models, logistic regression, and Gaussian processes, plus guidance on prior choice and diagnostic thresholds.
How it works
- Prepare data: standardize predictors, define named coordinates for readability.
- Define Model and Priors: inside a PyMC Model context, specify priors (e.g., Normal, HalfNormal), build the linear predictor mu, and set the likelihood (e.g., Normal with observed data). Use dims/coords where applicable.
- Prior Predictive Check: sample_prior_predictive to assess prior plausibility against observed data ranges.
- Sample Posterior: run pm.sample with draws, tune, chains, and idata_kwargs for log_likelihood when needed.
- Diagnose Sampling: compute and inspect summary with mean, sd, hdi, r_hat, ess; check for divergences and visual diagnostics (trace, rank plots).
- Posterior Predictive Check: sample_posterior_predictive and plot_ppc to compare simulated vs observed data.
- Compare Models: use az.compare with ic="loo" or WAIC; inspect Pareto-k diagnostics for reliability.
- Generate Predictions: set new data with pm.set_data and sample_posterior_predictive to obtain y_obs predictions with uncertainty.
When to use it
- When estimating parameters with full uncertainty quantification (credible intervals).
- When fitting hierarchical/multilevel models to grouped data.
- When performing prior and posterior predictive checks to validate model assumptions.
- When comparing candidate models using LOOCV/WAIC.
- When building regression models (linear, logistic, Poisson) in a Bayesian framework and handling missing data as latent parameters.
- When modeling time series or Gaussian processes for nonlinear relationships.
What it can touch
- Prerequisites: Python packages pymc>=5.0, arviz, numpy, matplotlib.
- Data: NumPy arrays or pandas DataFrames with numeric columns.
- Environment: CPU; GPU via JAX backend for large models (optional).
Caveats
- License is Apache-2.0.
- Guidance includes cautions on priors and diagnostics; performance notes indicate GP scales poorly for large n and may require sparse approximations.
- The workflow emphasizes diagnostic thresholds (R-hat, ESS, divergences) and model comparison caveats (Pareto-k diagnostics).
# PyMC Bayesian Modeling ## Overview PyMC is a Python library for Bayesian statistical modeling and probabilistic programming. It provides an expressive syntax for defining probabilistic models and efficient inference via MCMC (NUTS) and variational methods (ADVI). This skill covers the full Bayesian modeling cycle from model specification through diagnostics, comparison, and prediction. ## When to Use - Estimating parameters with full uncertainty quantification (credible intervals, not just point estimates) - Fitting hierarchical/multilevel models to grouped or nested data - Performing prior and posterior predictive checks to validate model assumptions - Comparing candidate models using information criteria (LOO-CV, WAIC) - Building regression models (linear, logistic, Poisson) in a Bayesian framework - Handling missing data or measurement error as latent parameters - Modeling time series with autoregressive or random walk priors - Generating posterior predictions for new observations with uncertainty bounds - Use **Stan/PyStan** instead for compiled, more scalable Bayesian inference on large models; use **statsmodels** for frequentist statistical tests ## Prerequisites - **Python
- Overview
- When to Use
- Prerequisites
- Quick Start
- Workflow
- Step 1: Prepare Data
- Step 2: Define Model and Set Priors
- Step 3: Prior Predictive Check
- Step 4: Sample Posterior (MCMC)
- Step 5: Diagnose Sampling
- Step 6: Posterior Predictive Check
- Step 7: Compare Models
- Step 8: Generate Predictions
- Key Parameters
pip install pymc arviz numpy matplotlib pip install pymc[jax]
What does the pymc-bayesian-modeling skill do?
Bayesian modeling with PyMC 5: priors, likelihood, NUTS/ADVI sampling, diagnostics (R-hat, ESS), LOO/WAIC comparison, prediction. Hierarchical, logistic, GP variants; predictive checks.
How do I install it?
Run `npx skills add BioTender-max/awesome-bio-agent-skills --skill pymc-bayesian-modeling --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From BioTender-max/awesome-bio-agent-skills, a repository with 135 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
