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

Add khat and ps_min_ss #20

Merged
merged 13 commits into from
Sep 18, 2024
Merged

Add khat and ps_min_ss #20

merged 13 commits into from
Sep 18, 2024

Conversation

aloctavodia
Copy link
Contributor

@aloctavodia aloctavodia commented Aug 8, 2024

This is just a placeholder, the goal is to eventually have a function to compute the min_ss as discussed here. The original implementation is here. There a lot of other functions implemented (also discussed in the vignette from the first link), I think we don't want those other functions, at least not now.

I checked that I am getting the same result as in the vignette (to be sure I installed the Posterior package, I got the value of mu and converted it into a DataArray)

mu <- extract_variable_matrix)(example_draws(), "mu")
pareto_diags(mu)
#> $khat
#> [1] 0.1979001
#> 
#> $min_ss
#> [1] 17.6493

This is an example of how to run the function, first compute the k-hat and then the min_ss

sc = az.load_arviz_data("centered_eight")

mu = sc.posterior["mu"]
k = pareto_khat(mu)
ps_min_ss(k)

Notice that a lot of this code overlaps with the code necessary to compute the pareto smoothing part of the PSIS-CV-LOO method (notice the "log_weights" argument in the code in this PR). So eventually we will need to use some of this code for LOO too.


📚 Documentation preview 📚: https://arviz-stats--20.org.readthedocs.build/en/20/

@aloctavodia aloctavodia marked this pull request as ready for review September 12, 2024 14:52
@aloctavodia aloctavodia changed the title [WIP] add khat and ps_min_ss Add khat and ps_min_ss Sep 12, 2024
src/arviz_stats/accessors.py Outdated Show resolved Hide resolved
src/arviz_stats/base/pareto.py Outdated Show resolved Hide resolved
src/arviz_stats/base/diagnostics.py Outdated Show resolved Hide resolved
src/arviz_stats/base/dataarray.py Show resolved Hide resolved
src/arviz_stats/base/array.py Outdated Show resolved Hide resolved
Copy link
Member

@OriolAbril OriolAbril left a comment

Choose a reason for hiding this comment

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

Let's merge this first, then rebase the 1d ess PR on top of that and add support for 1d arrays to ess/mcse/pareto_min_ss everywhere in that PR

@OriolAbril OriolAbril merged commit 686f893 into main Sep 18, 2024
4 checks passed
@OriolAbril OriolAbril deleted the khat branch September 18, 2024 15:58
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