arviz-python

Diagnose and compare Bayesian inference results with ArviZ DataTree groups.

Updated Aug 12, 2026
One-click install
npx skills add https://github.com/schattenspiegel/skill-foundry-skills --skill arviz-python-schattenspiegel
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: arviz-python
Source: https://github.com/schattenspiegel/skill-foundry-skills/tree/main/skills/arviz-python
Command: npx skills add https://github.com/schattenspiegel/skill-foundry-skills --skill arviz-python-schattenspiegel

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires arviz, numpy, xarray, and includes references (resource) components.

What problem does it solve? Bayesian analysis code often mishandles posterior artifacts: chains get flattened, groups get mislabeled, and diagnostics like R-hat or PSIS-LOO get reported without the checks that make them meaningful. This Skill guides writing, reviewing, debugging, and testing Python code that uses ArviZ so inference data keeps correct chain/draw structure, coordinates, and provenance. ## Core Features & Use Cases - Labeled conversion: Convert raw chain x draw x domain arrays into ArviZ 1.x DataTree groups with explicit dims, coords, and uniqueness assertions. - Convergence diagnostics: Apply rank R-hat, bulk/tail ESS, MCSE, and sampler statistics correctly, reporting problematic variables and coordinates rather than a single global number. - Predictive checks and model comparison: Run posterior predictive checks and PSIS-LOO comparisons only when observations, likelihood targets, and pointwise log likelihood are compatible, with Pareto-k inspection. - Use Case: You receive flattened MCMC samples from a colleague's PyMC run. Use this Skill to reshape them into chain x draw x feature arrays, build a labeled DataTree, verify convergence per coordinate, and compare against a baseline model with valid pointwise log likelihood. ## Quick Start Ask the AI to convert your posterior arrays into a labeled ArviZ DataTree and run convergence diagnostics with R-hat, ESS, and MCSE per variable.

Frequently Asked Questions about arviz-python

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

FAQPage Schema
How do I convert NumPy arrays to ArviZ InferenceData?▼

Use az.from_dict with a nested group mapping like {"posterior": {"beta": values}} plus explicit dims and coords. Arrays should be chain x draw x domain; assert coordinate lengths and uniqueness before conversion and reject ambiguous flattened samples.

How do I check MCMC convergence in ArviZ?▼

Combine rank-normalized R-hat, bulk and tail ESS, MCSE, and trace or rank plots, reporting the affected variable and coordinate. Keep chains separate; R-hat near one is necessary but not sufficient, and one chain cannot provide between-chain evidence.

Does ArviZ 1.x still use InferenceData?▼

ArviZ 1.x uses an xarray DataTree as its inference container, though some integrations still return or call it InferenceData. Inspect the installed version and API rather than assuming 0.x group access, keywords, or the removed ic="loo" argument in compare.

Why does PSIS-LOO model comparison fail in ArviZ?▼

Comparison requires pointwise log likelihood for identical observation units across candidate models. It fails or misleads when models use different filtered rows, likelihood factorizations, or response transformations; inspect Pareto-k values and uncertainty before ranking.

When should I not use ArviZ for analysis?▼

Do not use it to construct or sample PyMC, NumPyro, or Bambi models, for generic plotting unrelated to posterior results, or for deterministic statistics without Bayesian draws. It operates on completed or partial Bayesian draws, not model building.