Do operator on multiple variables in model

Yes: Distributional do-operator? - #2 by ricardoV94
We should add it to the docstrings.

pm.observe affects the logp graph, whereas do affects the generative graph. The former won’t have any meaningful effect when doing prior/posterior predictive sampling.

pm.do or pm.MutableData simply modify the underlying model. Sometimes what you want can be easily achieved by this, other times it’s too cumbersome.

The approach shown in that article is the most general possible: you manually write the new model and feed the inferred trace to it. You can do whatever do and set_data achieve and much more. It’s just a question of how complex your “intervention” / “conditional predictions” look like, which will determine the best approach.

2 Likes