Skip to content
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

Use Split R-hat #477

Merged
merged 7 commits into from
Dec 31, 2018
Merged

Use Split R-hat #477

merged 7 commits into from
Dec 31, 2018

Conversation

ahartikainen
Copy link
Contributor

@ahartikainen ahartikainen commented Dec 31, 2018

Update R-hat calculation to use Split R-hat described in BDA3.

Follows calculation done in https://github.com/stan-dev/pystan/blob/develop/pystan/_chains.pyx

@ahartikainen
Copy link
Contributor Author

mc = "parameters { real y;} model { y ~ normal(0,3);}"
sm = pystan.StanModel(model_code=mc)
fit = sm.sampling()
idata = az.from_pystan(posterior=fit)

Will yield

pystan._chains.split_potential_scale_reduction(fit.sim, 0)
# 1.0033341784610692
az.stats.diagnostics._get_split_rhat(idata.posterior.y.values, round_to=16)
# 1.0033341784610692

shape = values.shape
if len(shape) != 2:
raise TypeError("Effective sample size calculation requires 2 dimensional arrays.")
_, num_samples = shape

num_split = num_samples // 2
# Calculate split chain mean
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for comments!

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.

2 participants