# Do operator on multiple variables in model

**URL:** <https://discourse.pymc.io/t/do-operator-on-multiple-variables-in-model/13092>\
**Category:** v5\
**Tags:** modeling\
**Created:** [October 13, 2023, 5:32am UTC](https://discourse.pymc.io/t/do-operator-on-multiple-variables-in-model/13092 "2023-10-13T05:32:37Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![ricardoV94](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/ricardov94/32/5775_2.png) [@ricardoV94](https://discourse.pymc.io/u/ricardoV94)\
**Post date:** [October 16, 2023, 9:11am UTC](https://discourse.pymc.io/t/do-operator-on-multiple-variables-in-model/13092/6 "2023-10-16T09:11:18Z")

</div>

> [@JAB](#):
>
> Is it possible to perform the intervention but with variables being sampled from a distribution?

Yes: [Distributional do-operator? - #2 by ricardoV94](https://discourse.pymc.io/t/distributional-do-operator/12915/2)  
We should add it to the docstrings.

> [@JAB](#):
>
> How does `pm.set_data` compare to `pm.observe` in the context of using the `do` operator?

`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.

> [@JAB](#):
>
> I am still not clear if that example notebook completely applies.

`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.

---

_[View the full topic](https://discourse.pymc.io/t/do-operator-on-multiple-variables-in-model/13092)._
