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

Check MCMC convergence #74

Open
dp-rice opened this issue Sep 17, 2024 · 0 comments
Open

Check MCMC convergence #74

dp-rice opened this issue Sep 17, 2024 · 0 comments

Comments

@dp-rice
Copy link
Collaborator

dp-rice commented Sep 17, 2024

Charlie suggested that we report R-hat to assess the convergence and mixing of our posterior samples. Here's a snippet of code that calculates it for our parameter b, the overall P2RA coefficient (not the location-specific coefficients):

import arviz as az

model.fit_model(num_samples=num_samples)

coeffs = model.get_coefficients()
rhat = az.rhat(
    coeffs[coeffs["location"] == "Overall"]
    .to_numpy()
    .reshape((num_samples, -1))
    .T
)

@simonleandergrimm , you'll have to add arviz to the requirements, add this to fit.py, and then decide how/where you want to report rhat.

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

No branches or pull requests

1 participant