Skip to content

Support for Posterior SBC and misc #51

Closed
Cab14bacc wants to merge 30 commits into
arviz-devs:mainfrom
Cab14bacc:feat/Posterior_SBC
Closed

Support for Posterior SBC and misc #51
Cab14bacc wants to merge 30 commits into
arviz-devs:mainfrom
Cab14bacc:feat/Posterior_SBC

Conversation

@Cab14bacc
Copy link
Copy Markdown
Contributor

@Cab14bacc Cab14bacc commented May 4, 2026

Closes #12 and referenced #49
Depends on #53 and #52

This PR introduces support for Posterior SBC using PyMC Models. Given original posterior samples, generate posterior predictive samples, augment them with the original observed data, sample from posterior conditioned on the augmented data, and compute rank statistics comparing the original posterior samples and the augmented posterior samples.

Constraint of Implmentation

Posterior SBC augments the observed data (concatenating original + replicated), which changes its size. For this to work, store observed data in pm.Data containers, and specify size using the dims parameter instead of setting a static shape.

If your model uses dims and coords, you are also responsible for resizing them to the correct size corresponding to the new augmented dataset via the update_data callback. Similarly, if your model has covariates, store them in pm.Data so they can be resized in the same callback.

New Parameters for SBC Class

  • method="posterior": You can now pass an original trace (containing posterior distributions) alongside method="posterior" to execute Posterior SBC.
  • Custom Callbacks: These are included to deal with needed updates to the model when conditioning on the augmented dataset.
    • augment_observed: Custom logic for how to augment the posterior predictive sample and the observed data, the default behavior is to concatenate on the first axis.
    • update_data: Called before conditioning on the augmented dataset. custom logic to update the covariates, coords to conform to the new augmented data. There is no default behavior, but if user does not modify variable that are of type pm.Data that are used for observed data, the code will update according to the augmented data.

Misc

  • Added tests for posterior sbc.
  • Added toy example for posterior sbc.

@Cab14bacc Cab14bacc changed the title Implement Posteior SBC Support for Posterior SBC May 4, 2026
@Cab14bacc Cab14bacc changed the title Support for Posterior SBC Support for Posterior SBC and misc May 4, 2026
@aloctavodia
Copy link
Copy Markdown
Contributor

Better to restrict this PR to posterior SBC and have separate PRs for other features like bug fixes, new functions, etc.

Cab14bacc added 21 commits May 6, 2026 16:07
…ation of rank statistics of another quantity via compute_rank_statistics
…posterior sbc example, added quickstart for posterior sbc
…ation of rank statistics of another quantity via compute_rank_statistics
…posterior sbc example, added quickstart for posterior sbc
@Cab14bacc Cab14bacc closed this May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add posterior SBC

2 participants