Skills pymc-bayesian-modeling
📊

pymc-bayesian-modeling

Safe ⚙️ External commands📁 Filesystem access

Build Bayesian Models with PyMC

Also available from: davila7

Build, fit, and validate Bayesian models using PyMC. Create hierarchical models, run MCMC sampling, and compare models with LOO and WAIC metrics.

Supports: Claude Codex Code(CC)
🥈 79 Silver
1

Download the skill ZIP

2

Upload in Claude

Go to Settings → Capabilities → Skills → Upload skill

3

Toggle on and start using

Test it

Using "pymc-bayesian-modeling". Build a Bayesian linear regression with predictors X1, X2 and outcome y

Expected outcome:

  • Model: alpha ~ Normal(0,1), beta ~ Normal(0,1), sigma ~ HalfNormal(1)
  • Posterior means with 95% credible intervals
  • R-hat values all below 1.01 indicating convergence
  • Posterior predictive checks showing model fit

Using "pymc-bayesian-modeling". Create a hierarchical model with 10 groups and 50 observations each

Expected outcome:

  • Population-level hyperparameters: mu_alpha, sigma_alpha, mu_beta, sigma_beta
  • Group-level parameters showing shrinkage toward population mean
  • Trace plots confirming good mixing
  • Comparison of group intercepts with forest plot

Using "pymc-bayesian-modeling". Compare three model specifications using LOO

Expected outcome:

  • LOO comparison table with rank, elpd_loo, and weights
  • Pareto-k diagnostics for each model
  • Recommendation for best model with interpretation
  • Model-averaged predictions if models are similar

Security Audit

Safe
v4 • 1/17/2026

All 383 static findings are false positives. The 'weak cryptographic algorithm' detections flag legitimate PyMC probability distributions. The 'external_commands' findings flag markdown backtick syntax. This is a legitimate scientific computing skill for Bayesian statistical modeling.

9
Files scanned
3,435
Lines analyzed
2
findings
4
Total audits
Audited by: claude View Audit History →

Quality Score

82
Architecture
100
Maintainability
87
Content
20
Community
100
Security
78
Spec Compliance

What You Can Build

Uncertainty Quantification

Quantify uncertainty in regression coefficients and predictions using full posterior distributions.

Hierarchical Data Analysis

Analyze grouped or nested data structures with partial pooling across groups.

Model Comparison

Compare competing statistical models using LOO cross-validation and model weights.

Try These Prompts

Simple Linear Regression
Build a Bayesian linear regression model using PyMC with the following predictors and outcome variable. Include prior predictive checks, sample the posterior using NUTS, and check convergence diagnostics.
Hierarchical Model
Create a hierarchical Bayesian model for data with group structure. Use non-centered parameterization to avoid sampling issues. Show group-level estimates and shrinkage toward the population mean.
Model Comparison
Fit two or more Bayesian models to the same data and compare them using LOO. Report the model weights and provide interpretation guidelines for the comparison results.
Full Workflow
Run a complete Bayesian analysis workflow including data preparation, model building, prior predictive checks, MCMC sampling with 4 chains, convergence diagnostics, posterior predictive checks, and predictions for new data.

Best Practices

  • Standardize predictors before modeling to improve sampling efficiency
  • Use weakly informative priors rather than flat priors for better inference
  • Always run prior predictive checks before fitting to validate priors
  • Check convergence diagnostics (R-hat < 1.01, ESS > 400, no divergences) before interpreting results

Avoid

  • Using flat priors (Uniform(0, 1e10)) instead of informative priors
  • Interpreting results without checking convergence diagnostics
  • Using centered parameterization for hierarchical models (causes divergences)
  • Fitting complex models without prior predictive checks

Frequently Asked Questions

What is PyMC?
PyMC is a Python library for probabilistic programming that enables Bayesian modeling and Markov Chain Monte Carlo sampling.
What is MCMC sampling?
MCMC (Markov Chain Monte Carlo) is a family of algorithms that generate samples from a probability distribution when direct sampling is difficult.
What is the NUTS algorithm?
NUTS (No-U-Turn Sampler) is an adaptive Hamiltonian Monte Carlo algorithm that automatically tunes step size and trajectory length.
What are priors in Bayesian analysis?
Priors represent knowledge or beliefs about parameters before observing data. They are combined with data through Bayes theorem to produce posteriors.
What is R-hat?
R-hat (Gelman-Rubin statistic) measures convergence across chains. Values below 1.01 indicate good convergence.
When should I use hierarchical models?
Use hierarchical models when data has grouped or nested structure, allowing partial pooling of information across groups.