pymc

Build, fit, and validate Bayesian models with PyMC using MCMC and variational inference.

Updated Sep 2, 2026
One-click install
npx skills add https://github.com/ricfulop/cba-agentic-engineering-bootstrap --skill pymc-ricfulop
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pymc
Source: https://github.com/ricfulop/cba-agentic-engineering-bootstrap/tree/main/skills/pymc
Command: npx skills add https://github.com/ricfulop/cba-agentic-engineering-bootstrap --skill pymc-ricfulop

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires pymc, arviz, numpy, pandas, matplotlib, and includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve? Building Bayesian models correctly requires navigating prior selection, MCMC sampling, convergence diagnostics, and model comparison, where mistakes like divergences or poor parameterization silently invalidate results. ## Core Features & Use Cases - Standard Bayesian Workflow: Guides the full pipeline from data preparation and prior predictive checks through NUTS sampling, diagnostics, and posterior predictive validation. - Model Templates & Patterns: Provides ready-to-customize templates for linear regression, logistic regression, hierarchical models, Poisson regression, and time series with non-centered parameterization. - Diagnostics & Comparison Scripts: Includes automated R-hat, ESS, and divergence checks plus LOO/WAIC model comparison and Bayesian model averaging utilities. - Use Case: A researcher modeling grouped experimental data can start from the hierarchical model template, fit with NUTS, verify convergence with the diagnostics script, and compare against simpler models using LOO. ## Quick Start Use the pymc skill to build a Bayesian hierarchical regression model for my grouped dataset and check the sampling diagnostics.

Frequently Asked Questions about pymc

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

FAQPage Schema
How do I build a Bayesian hierarchical model in PyMC?

Define hyperpriors for population-level parameters, then use non-centered parameterization for group-level effects by sampling offset variables and scaling them deterministically. This avoids divergences common in hierarchical models with centered parameterization.

How do I fix divergences in PyMC NUTS sampling?

Increase target_accept to 0.95 or 0.99, switch hierarchical models to non-centered parameterization, and add stronger priors to constrain parameters. Persistent divergences may indicate model misspecification requiring structural changes.

What is the difference between MCMC and variational inference in PyMC?

MCMC with NUTS provides accurate full posterior samples but is slower, while ADVI variational inference approximates the posterior much faster at the cost of underestimating uncertainty. Use ADVI for exploration or initialization, then MCMC for final inference.

How do I compare Bayesian models using LOO in PyMC?

Fit each model with idata_kwargs={'log_likelihood': True}, then call az.compare with ic='loo' to rank models. Check Pareto-k diagnostics to confirm LOO reliability, and consider WAIC or k-fold CV when k values exceed 0.7.

What R-hat and ESS values indicate PyMC convergence?

R-hat below 1.01 for all parameters indicates chains have converged, and effective sample size above 400 indicates sufficient independent samples. The included diagnostics script checks both automatically along with divergences and tree depth.