Open
Conversation
This notebook demonstrates the ZeroSumNormal distribution, which was introduced in PyMC v4.2.2. It covers: - Why sum-to-zero constraints are needed for identifiability - How design matrices create linear dependence with categorical predictors - Contrast coding schemes (reference vs sum-to-zero) - Mathematical foundations of ZeroSumNormal - Practical example comparing group means - Advanced usage with multiple zero-sum axes Based on the original concept from PR pymc-devs#210 by Benjamin T. Vincent and Adrian Seyboldt, rewritten for PyMC v5. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a comprehensive example notebook demonstrating PyMC's
ZeroSumNormaldistribution, which is ideal for categorical regression with sum-to-zero constraints.What this notebook covers:
Background
This continues the work started in #210 by @drbenvincent and @aseyboldt. The original PR from 2021 used PyMC3 with a custom ZeroSumNormal implementation. Since PyMC v4.2.2 (Oct 2022),
pm.ZeroSumNormalis available natively, making this much simpler.I've completely rewritten the notebook for modern PyMC v5, focusing on:
Checklist
RANDOM_SEEDfor reproducibilityTarget column in tracker
Done - This is a complete, new notebook using PyMC v5 best practices.
Closes #210
🤖 Generated with Claude Code