-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Strange samples from multilevel model with bounded distributions #5668
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
Comments
This is probably the same problem described in #4643 The multiple children and the parent are likely inducing some extreme correlated rejection sampling. Plotting the parent variable together with those pair plots might help understand how exactly Edit: Removed wild conjecture. |
Anyway, it's better not to use prior predictive with Bounded variables, because they do not respect the hierarchical conditional independence necessary for correct forward draws. This was in fact disabled in the next major release of PyMC |
I checked and it has nothing to do with the multiple children. I think the random method of bound was simply broken: import arviz as az
import pymc3 as pm
with pm.Model():
BoundedNormal = pm.Bound(pm.Normal, lower=0.0)
parent = BoundedNormal("parent", mu=1.0, sigma=0.4)
child = BoundedNormal(f"child", mu=parent, sigma=0.05)
prior_samples = pm.sample_prior_predictive(10000, random_seed=1)
az.plot_pair(prior_samples, var_names=["parent", "child"]) lower = 0.0If I set the lower bound to smaller and smaller values, it gets better: lower = -0.5:lower = -1.0My best guess at the moment, is that when the Bounded distribution has to resample values, it "forgets" the hierarchical dependency, leading to that uncorrelated blob. Somehow, in the first set of draws this dependency is still maintained. |
I'm getting strange samples from this simple multilevel model with bounded priors:
Inspecting the bivariate plots for the
child
prior samples:We see two distributions superimposed in each subplot:
parent
is outside the bound (lower than 0). I'm not sure if this is expected behaviour but it is alluded to in Future of pm.Bound? #4800The puzzling thing is that there are many more of the uncorrelated samples in some
child
variables (e.g. see towards bottom left of plot). I doubt this is expected?NB. I'm bounding Gaussians here just for illustration purposes. I have seen
pm.TruncatedNormal
and this issue doesn't occur when it's used.Thanks for your work on this great library!
Versions and main components
The text was updated successfully, but these errors were encountered: