Skip to content

Feat parameter recovery plot#61

Draft
Cab14bacc wants to merge 13 commits into
arviz-devs:mainfrom
Cab14bacc:feat/parameter_recovery_plot
Draft

Feat parameter recovery plot#61
Cab14bacc wants to merge 13 commits into
arviz-devs:mainfrom
Cab14bacc:feat/parameter_recovery_plot

Conversation

@Cab14bacc

@Cab14bacc Cab14bacc commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

resolves #40
image

  • This implements the parameter recovery plot. This requires keep_fits=True, as we need it to compute the mean of each simulation, the credible interval, etc.

  • The backend adapters is moved to their own folders. The plotting function is added to plots.py, a wrapper for arviz_plots.plot_ecdf_pit is also added. This means we no longer need to manually import arviz_plots to get plot_ecdf_pit

  • The credible interval is quantile-based, 94% CI ranges from 3rd percentile, to 97th percentile.

  • The title indicates a expected coverage using the binomial distribution of the prior value landing in the CI, the empirical fraction of simulations whose CI contains the true/prior value, this expected coverage uses the binomial standard error, which accounts for the sampling noise from having a finite number sbc simulations, but doesn't consider the noise in the estimation of the CI from finite MCMC draws.

  • Implements tests for plots.py.

@review-notebook-app

Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@Cab14bacc
Cab14bacc marked this pull request as draft July 21, 2026 09:25
@Cab14bacc
Cab14bacc marked this pull request as ready for review July 21, 2026 20:49
@codecov-commenter

codecov-commenter commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.12%. Comparing base (912d019) to head (95d615e).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #61      +/-   ##
==========================================
+ Coverage   95.87%   97.12%   +1.24%     
==========================================
  Files           7       10       +3     
  Lines         631      904     +273     
==========================================
+ Hits          605      878     +273     
  Misses         26       26              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread simuk/plots.py

def plot_parameter_recovery(
sbc,
ci_prob=0.94,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to keep this in line with ArviZ? If that's the case, we can use the hardcoded value (the default value in ArviZ is 0.89) or take the value from arviz's rcparams.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More generally, I think we want to make this plot more arvizian. We are already using plot_ecdf_pit from ArviZ. By this I mean using plot_collection, visuals, etc, see https://python.arviz.org/projects/plots/en/latest/tutorials/plots_intro.html

Comment thread simuk/plots.py Outdated
Comment thread simuk/plots.py
return fig


def plot_ecdf(sbc, if_show=True):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ArviZ plots works with 3 backends, matplotlib, plotly and bokeh, this assumes it only use matplotlib (plt.show()). ArviZ's plots return a plotcollection object, using "pc" or "plot_collection" is a better choice that "fig"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, yeah I'll try to make it more arvizy

@Cab14bacc
Cab14bacc marked this pull request as draft July 24, 2026 09:55
Co-authored-by: Osvaldo A Martin <aloctavodia@gmail.com>
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 parameter recovery plot

3 participants