-
-
Notifications
You must be signed in to change notification settings - Fork 426
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add support for discrete variables in plot_bpv #1379
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1379 +/- ##
==========================================
- Coverage 91.72% 91.63% -0.10%
==========================================
Files 105 105
Lines 10941 10965 +24
==========================================
+ Hits 10036 10048 +12
- Misses 905 917 +12
Continue to review full report at Codecov.
|
I understood that the current loo-pit approximation is not appliable to discrete data. I had this in mind to implement some day https://doi.org/10.1111/j.1541-0420.2009.01191.x Disclaimer: I have yet to review the PR, will do it soon |
Right, loo-pit is not applicable to discrete data for the same reasons plot_bpv isn't . I will check that paper, thanks! |
It seems I need to think a little bit more about this. |
9c8431c
to
0bba9a5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will merge after fixing bokeh backend
tstat_pit_dens.size, | ||
n_ref, |
There was a problem hiding this 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 also needed in bokeh backend
@@ -83,6 +88,16 @@ def plot_bpv( | |||
obs_vals = obs_vals.flatten() | |||
pp_vals = pp_vals.reshape(total_pp_samples, -1) | |||
|
|||
print(obs_vals.shape, pp_vals.shape) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
debug?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just want to keep the users informed
There are some duplication, but I think we can move things to the main function maybe in another PR when we have time? |
fake = {"a": np.random.poisson(2.5, 1000)} | ||
fake_model = from_dict(posterior_predictive=fake, observed_data=fake) | ||
fake_obs = {"a": np.random.poisson(2.5, 100)} | ||
fake_pp = {"a": np.random.poisson(2.5, (10, 100))} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a 2 dim array this will be understood as a (chain, draw)
array, you should add a dimension at the beggining.
if pp_vals.ndim > 2: | ||
pp_vals = pp_vals.reshape(total_pp_samples, -1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this will break the ArviZ shape convention and interpret the draw dimension as the observations.
Will merge once/if tests pass and release |
Fix
plot_bpv
to work with discrete variables. A similar fix could be applied toplot_loopit
It also add an option (default to false) to plot the mean square error between the uniform distribution and marginal p_value
Old


New


data =np.random.binomial(n=1, p=0.5, size=1000)
with pm.Model() as momo:
p = pm.Beta("p", 1., 1.)
data = np.random.binomial(n=1, p=0.5, size=50)
with pm.Model() as momo:
p = pm.Beta("p", 1., 1.)
data = np.random.binomial(n=1, p=0.5, size=100)
with pm.Model() as momo:
p = pm.Beta("p", 1., 1.)
data =np.random.binomial(n=1, p=0.5, size=100)
with pm.Model() as momo:
p = pm.Beta("p", 100., 1.)
data =np.random.binomial(n=1, p=0.8, size=100)


with pm.Model() as momo:
p = pm.Beta("p", 50, 50)
data = np.random.poisson(2.5, size=1000)
with pm.Model() as momo:
p = pm.Uniform('p', 0, 10)
data = np.random.poisson(2.5, size=1000)
with pm.Model() as momo:
p = pm.Uniform('p', 3, 10)
data = np.random.poisson(2.5, size=1000)
data[:100] = 4
with pm.Model() as momo:
p = pm.Uniform('p', 0, 10)
The two following
examples are not affected by this PR, but I add them here as reference.
normal model sample size= 1000


normal model sample size= 100