bambi icon indicating copy to clipboard operation
bambi copied to clipboard

Possibility to pick number of samples for calls to posterior predictive?

Open AlexanderFengler opened this issue 1 year ago • 4 comments

It is often useful / sufficient for posterior predictives (examples for purposes of plotting) to be based on less than all samples from a given call to .fit().

It seems like currently one cannot pick the number of samples at the level of the posterior predictive.

Would it be possible to add this as a small feature (or allow passing through of such parameter to the pm.sample_posterior_predictive() call?

AlexanderFengler avatar Oct 18 '23 20:10 AlexanderFengler

It's definitely possible but not 100% trivial. Bambi does not use pm.sample_posterior_predictive() under the hood (maybe we should!). It uses pm.draw(dist(**kwargs)) and the number of draws we obtain depends on the shape of the array(s) in kwargs. To decrease the number of draws from the posterior predictive distribution we should first downsample the posterior draws. I'll check what PyMC does in these cases. Maybe the answer is that we should move to pm.sample_posterior_predictive().

tomicapretto avatar Oct 20 '23 13:10 tomicapretto

@tomicapretto We implemented a temporary solution which just samples the posterior group of the trace object and then pass it to model.predict. Do you foresee issues with this?

digicosmos86 avatar Oct 26 '23 15:10 digicosmos86

@tomicapretto We implemented a temporary solution which just samples the posterior group of the trace object and then pass it to model.predict. Do you foresee issues with this?

Nope, I think we could use it in Bambi. Do you have it somewhere? Feel free to open a PR, or I can open one myself. Thanks!

tomicapretto avatar Oct 26 '23 20:10 tomicapretto

@tomicapretto Sure! I'll do a PR soon. Thanks!

digicosmos86 avatar Oct 29 '23 12:10 digicosmos86