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

UserWarning if doing predictive sampling with models containing Potentials #4419

Merged
merged 4 commits into from
Jan 16, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions pymc3/sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -1692,6 +1692,13 @@ def sample_posterior_predictive(

model = modelcontext(model)

if model.potentials:
warnings.warn(
"The effect of Potentials on other parameters is ignored during posterior predictive sampling. "
"This is likely to lead to invalid or biased predictive samples.",
UserWarning,
)

if var_names is not None:
vars_ = [model[x] for x in var_names]
else:
Expand Down Expand Up @@ -1791,6 +1798,15 @@ def sample_posterior_predictive_w(
if models is None:
models = [modelcontext(models)] * len(traces)

for model in models:
if model.potentials:
warnings.warn(
"The effect of Potentials on other parameters is ignored during posterior predictive sampling. "
"This is likely to lead to invalid or biased predictive samples.",
UserWarning,
)
break

if weights is None:
weights = [1] * len(traces)

Expand Down Expand Up @@ -1903,6 +1919,13 @@ def sample_prior_predictive(
"""
model = modelcontext(model)

if model.potentials:
warnings.warn(
"The effect of Potentials on other parameters is ignored during prior predictive sampling. "
"This is likely to lead to invalid or biased predictive samples.",
UserWarning,
)

if var_names is None:
prior_pred_vars = model.observed_RVs
prior_vars = (
Expand Down