From 120fc4ece8eff45ecb78f7e1a4d0144cf809bba1 Mon Sep 17 00:00:00 2001 From: Ricardo Vieira Date: Wed, 27 Mar 2024 14:48:11 +0100 Subject: [PATCH] Improve example on expanded sample_posterior_predictive Sample posterior_predictive relies on other groups to infer volatility, so it's important to keep the whole InferenceData. Also there's a shape error if `sample_dims` is not specified --- pymc/sampling/forward.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pymc/sampling/forward.py b/pymc/sampling/forward.py index 3a1fc5a785..b63b9850a2 100644 --- a/pymc/sampling/forward.py +++ b/pymc/sampling/forward.py @@ -711,9 +711,14 @@ def sample_posterior_predictive( .. code:: python - expanded_data = idata.posterior.expand_dims(pred_id=5) + expanded_idata = idata.copy() + expanded_idata.posterior = idata.posterior.expand_dims(pred_id=5) with model: - idata.extend(pm.sample_posterior_predictive(expanded_data)) + pm.sample_posterior_predictive( + expanded_idata, + sample_dims=["chain", "draw", "pred_id"], + extend_inferencedata=True, + ) """