bayesplot icon indicating copy to clipboard operation
bayesplot copied to clipboard

Local ESS, quantile ESS, ESS change, and rank-based alternative to traceplot

Open tjmahr opened this issue 5 years ago • 15 comments

Edit: Sorry @tjmahr, that I (Aki) hijack this issue.

Implement new plots as described in

  • Aki Vehtari, Andrew Gelman, Daniel Simpson, Bob Carpenter, Paul-Christian Bürkner (2019): Rank-normalization, folding, and localization: An improved R-hat for assessing convergence of MCMC. arXiv preprint arXiv:1903.08008.

See also Dan's blog post

The reference code is available in monitorplot.R

Implement versions of functions

  • [x] mcmc_rank_hist, mcmc_rank_overlay for rank plots
  • [x] mcmc_ecdfd_r_scale for ECDF difference plots (see Fig. 14c in SBC paper)
  • [ ] mcmc_ess_local for local efficiency plots
  • [ ] mcmc_ess_quantile for quantile efficiency plots
  • [ ] mcmc_ess_change for efficiency change plots

Feel free to come up with better function names, add checks, and it's fine to make separate PRs for these, if you want to implement just one.

For three last ones see also stan-dev/rstan#617

tjmahr avatar Mar 20 '19 02:03 tjmahr

@tjmahr's comments on rank plot

  • If we take the input into mcmc_trace(), we know the chain id and values of the iterations. Then we can compute ranks with dplyr::row_number() and facet by chain id.
  • Sanity check: Plot should be perfectly uniform when model has just one chain. Edit (Aki): The model should never have just one chain.

avehtari avatar Mar 20 '19 10:03 avehtari

@tjmahr, @paul-buerkner, @jgabry suggestions for the function names?

avehtari avatar Mar 20 '19 10:03 avehtari

I think we could also use the mcmc_ prefix for the ESS plots, something like:

mcmc_ess_local
mcmc_ess_quantile
mcmc_ess_change

The rank plots could simply be named mcmc_rank or similar.

paul-buerkner avatar Mar 20 '19 16:03 paul-buerkner

I've been traveling and am just catching up on this. I like the function names suggested by @paul-buerkner

jgabry avatar Mar 25 '19 20:03 jgabry

Related to this issue, we'll also need to update the bayesplot MCMC diagnostics vignette.

jgabry avatar Apr 08 '19 18:04 jgabry

Added to todo list: mcmc_ecdfd_r_scale for ECDF difference plots (see Fig. 14c in SBC paper)

avehtari avatar Apr 12 '19 18:04 avehtari

example of mcmc_ecdfd_r_scale plot https://twitter.com/avehtari/status/1122940123522502657

avehtari avatar Apr 30 '19 08:04 avehtari

Thanks Aki

jgabry avatar Apr 30 '19 18:04 jgabry

Would it be possible to add a facet_args argument to mcmc_rank_overlay()?

ASKurz avatar Jun 12 '20 15:06 ASKurz

Yeah I actually recently merged a PR from @hhau that added this (https://github.com/stan-dev/bayesplot/pull/221), so it should be available now if you install bayesplot from GitHub.

jgabry avatar Jun 12 '20 16:06 jgabry

Excellent! Thanks for the heads up.

ASKurz avatar Jun 12 '20 16:06 ASKurz

Hi all. It looks like there hasn't been any activity here for a while. Is there still interest in pursuing the remaining plot functions from this issue?

timwaterhouse avatar Oct 20 '22 15:10 timwaterhouse

ECDF difference plots were added by #282 ess-plots are still missing, but it would be nice to have them

avehtari avatar Oct 23 '22 11:10 avehtari

Would a PR be welcome for those ESS plots that essentially collects the relevant code from @avehtari's reference code (along with tests etc)? Are there some complexities about bayesplot that I'd need to be aware of to make this work?

timwaterhouse avatar Nov 15 '22 14:11 timwaterhouse

Would a PR be welcome

Yes! You can make a PR, and Jonah can then provide feedback to take into account the bayesplot requirements

avehtari avatar Nov 15 '22 15:11 avehtari