New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added support for emcee in arviz #279
Comments
Hey Colin, thanks for this! We don't currently store per-draw stats for emcee, but I would like to include it at some point. It probably won't make it into v3.0, but hopefully soon! I'll keep you posted. The plot that I always struggle to make with pymc3 in a consistent way is a nice corner plot (like your pair_plot but using corner.py). I haven't looked at arviz in detail, but an interface that could work easily with that would be awesome. (The problem occurs when some of the variables have non-scalar shapes - something that you must have an interface to deal with anyways!) Finally - it's worth noting that the chains produced by emcee are not independent so some care must be taken when doing convergence analysis. I don't think that this is necessarily a big problem, but we might want to include some sort of disclaimer so that people don't take the G-R statistic/n_eff without the proper caution. |
Quick question @dfm : I'm currently using PyMC3's effective_n function to estimate the effective sample size for samplers of both |
I haven't tested it thoroughly, but the assumptions are not satisfied. I'd recommend checking out this blog post for more discussion and recommended methods for ensemble methods: https://dfm.io/posts/autocorr/ |
Thank you Dan. If I understand what is stated in that post then I should simply estimate the effective sample size as |
Closing since this was just informative (though thanks for pointing out the effective_n calculation is wrong for this sampler!) |
Hey @dfm, I have been doing some experiments (posted on my blog) comparing autocorrelation/ess values using the algorithm in ArviZ and the one in emcee, and it looks like they both converge to the same value (and that the condition on Could you indicate which assumptions are not satisfied in the Gelman-Rubin algorithm? Maybe it affects only Any help or hints would be greatly appreciated. Thanks! |
@OriolAbril: That post looks great! All I meant by that is that the walkers in the stretch move are not formally independent so you'll be overly confident about your convergence if you treat them as independent. I'm sure it can still be a useful diagnostic! |
Yes! I understand this point, which is why I expected ArviZ version to underestimate the autocorrelation time. Thus, the effective sample size would be overestimated, and we would end up being overconfident with convergence. But what happens in all the examples I have looked into is the opposite of this. That is why i am having trouble trying to understand what exactly is going on. |
This may also be relevant to my previous question: https://discourse.mc-stan.org/t/does-effective-sample-size-estimation-require-independent-chains/ |
Yes - that response there is exactly what I was saying! The chains do communicate at every step so they don't satisfy the assumptions in that work. It is interesting that the method works well, but it's not obvious that it will work well in less trivial experiments... |
I know, what still confuses me is why do both methods converge to the same value and even worse, why does "Gelman" version overestimate the autocorrelation time instead of I will try to work out the maths in both approaches to see exactly where they differ and see if I can get why my intuition is not working. |
Both algorithms are doing the same, with only two differences, one of them I think is not relevant. My notation is The differences are the following:
I think that the normalization difference has no implication on whether the chains used for the autocovariance/autocorrelation computation must or must not be independent, so I am more confused than ever. I mean, I have understood why "Gelman" algorithm gives autocorrelation times larger or equal than emcee's version, but how is the dependence taken into account (if taken into account)? Or what is the same, where is independence required (if required)? Thanks for all your time! I hope I am not too annoying. |
Hello, |
Wanted to let you know we have added support for emcee to the arviz library - see arviz-devs/arviz#302 for a description of the change.
Roughly, the plan is for arviz to replace plotting and diagnostics for pymc3 (so we do not have to rewrite it for pymc4), by converting data to a common data format (netCDF/xarray datasets), and then implementing all the plots and diagnostics on that object. emcee is the third library to have support (pymc3 and pystan), after hearing so many astronomers saying nice things about it at a conference.
In addition to the plots you can see in the pull request above, you can also calculate things like the effective sample size and the gelman rubin statistic. The
summary
function below shows a number of these.Some questions I had -
sample_stats
from pystan and pymc3. Is there a way to access whether a sample was accepted at a per-draw basis inemcee
?The text was updated successfully, but these errors were encountered: