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 prior sense related functionality #24

Merged
merged 8 commits into from
Oct 16, 2024
Merged

Add prior sense related functionality #24

merged 8 commits into from
Oct 16, 2024

Conversation

aloctavodia
Copy link
Contributor

@aloctavodia aloctavodia commented Sep 19, 2024

Closes #23

From the user perspective the main addition in this PR is the psens_summary function, which is equivalent to powerscale_sensitivity from the priorsense package.

azs.psens_summary(sc)

	 prior	likelihood	diagnosis
mu      0.413	0.584	prior-data conflict
sigma	0.297	0.538	prior-data conflict

Where sc is a DataTree from a PyMC model equivalent to univariate_normal model in priorsense docs. Results are close to those, differences may be do to sampling differences, I need to check more carefully. There are also small differences compared to the result from az.psens (now the samples are the same).


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

@aloctavodia aloctavodia marked this pull request as draft September 19, 2024 15:24
@aloctavodia aloctavodia changed the title Psense Add prior sense related functionality Sep 20, 2024
@aloctavodia aloctavodia changed the title Add prior sense related functionality [WIP] Add prior sense related functionality Sep 20, 2024
@aloctavodia aloctavodia marked this pull request as ready for review September 20, 2024 19:06
@aloctavodia aloctavodia marked this pull request as draft October 3, 2024 17:42
@aloctavodia aloctavodia marked this pull request as ready for review October 3, 2024 19:28
src/arviz_stats/base/density.py Outdated Show resolved Hide resolved
src/arviz_stats/psens.py Outdated Show resolved Hide resolved
src/arviz_stats/psens.py Outdated Show resolved Hide resolved
src/arviz_stats/psens.py Outdated Show resolved Hide resolved
src/arviz_stats/psens.py Outdated Show resolved Hide resolved
src/arviz_stats/psens.py Outdated Show resolved Hide resolved
src/arviz_stats/psens.py Outdated Show resolved Hide resolved
src/arviz_stats/psens.py Outdated Show resolved Hide resolved
src/arviz_stats/psens.py Outdated Show resolved Hide resolved
src/arviz_stats/psens.py Outdated Show resolved Hide resolved
@OriolAbril
Copy link
Member

I have only looked at the psens function, not the psens_summary one. I think everything works as expected. Hopefully what is going on is somewhat clear. I think results shoud exactly match current arviz now, there was an issue in passing down the dimensions on which to operate dims->axes so instead of axes being defined from dims it was set to the default -1 (instead of the correct (-2, -1) when using data with chain, draw).

Now both:

import arviz_stats
from arviz_base import load_arviz_data, extract
idata = load_arviz_data("non_centered_eight")
arviz_stats.psens(idata, group="log_likelihood")

and

arviz_stats.psens(
    idata.drop_nodes(["prior", "prior_predictive", "observed_data", "constant_data"]).stack(sample=["chain", "draw"]),
    group="log_likelihood",
    sample_dims="sample"
)

work and return the same result.

@aloctavodia aloctavodia changed the title [WIP] Add prior sense related functionality Add prior sense related functionality Oct 8, 2024
src/arviz_stats/psense.py Show resolved Hide resolved
src/arviz_stats/psense.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.

I think this is nearly ready to merge, only some api and doc related points left

src/arviz_stats/psense.py Outdated Show resolved Hide resolved
@OriolAbril OriolAbril merged commit d622d99 into main Oct 16, 2024
4 checks passed
@OriolAbril OriolAbril deleted the psense branch October 16, 2024 19:05
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.

Add priorsense related functionality
3 participants