Add Poisson and NegativeBinomial to pymc.dims#8305
Merged
ricardoV94 merged 3 commits intoMay 20, 2026
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8305 +/- ##
==========================================
- Coverage 91.77% 91.73% -0.05%
==========================================
Files 125 125
Lines 20437 20471 +34
==========================================
+ Hits 18757 18779 +22
- Misses 1680 1692 +12
🚀 New features to boost your workflow:
|
ricardoV94
reviewed
May 20, 2026
ricardoV94
approved these changes
May 20, 2026
Member
ricardoV94
left a comment
There was a problem hiding this comment.
LGTM but I would make the alternative parameters keyword only
Co-authored-by: Ricardo Vieira <28983449+ricardoV94@users.noreply.github.com>
Member
|
thanks |
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
Add
PoissonandNegativeBinomialtopymc.dimsto unblock the Bass model dimension migration (pymc-labs/pymc-marketing#2598). These are the last two distributions needed before the Bass model can migrate fromcreate_dim_handlerto thexdist=True/pymc.dimspattern used by the rest of pymc-marketing.Changes
pymc/dims/distributions/scalar.py: AddPoisson(wrapsptxr.poisson, acceptsmu) andNegativeBinomial(wrapsptxr.nbinom, acceptsmu/alphaorn/pparameterization) asDimDistributionsubclassestests/dims/distributions/test_scalar.py: Addtest_poissonandtest_negative_binomialfollowing the existing pattern — create a model with the dims distribution + reference model with the regular distribution, assert equivalent random and logp graphsBackground
These are the first discrete count distributions in
pymc.dims.Poissonis the default likelihood for the Bass model, andNegativeBinomialis the alternative.DiracDeltais out of scope (can be handled by supporting non-Prior configurations in pymc-marketing).The underlying PyTensor xtensor operations (
ptxr.poisson,ptxr.nbinom) already existed — only thepymc.dimswrapper classes were missing.