Skip to content

Feat parameter recovery plot - #61

Open
Cab14bacc wants to merge 16 commits into
arviz-devs:mainfrom
Cab14bacc:feat/parameter_recovery_plot
Open

Feat parameter recovery plot#61
Cab14bacc wants to merge 16 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
depends on #62
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

❌ Patch coverage is 98.98305% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.82%. Comparing base (912d019) to head (7403c57).

Files with missing lines Patch % Lines
simuk/plots.py 97.85% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #61      +/-   ##
==========================================
+ Coverage   95.87%   96.82%   +0.94%     
==========================================
  Files           7        9       +2     
  Lines         631      914     +283     
==========================================
+ Hits          605      885     +280     
- Misses         26       29       +3     

☔ 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 Outdated

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 Outdated
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
@Cab14bacc
Cab14bacc force-pushed the feat/parameter_recovery_plot branch from 95d615e to 7403c57 Compare July 27, 2026 22:06
@Cab14bacc
Cab14bacc marked this pull request as ready for review July 27, 2026 22:14
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