# New PyMCon Talk Released: Bayesian Causal Modeling by Thomas Wiecki & Ben Vincent

**URL:** <https://discourse.pymc.io/t/new-pymcon-talk-released-bayesian-causal-modeling-by-thomas-wiecki-ben-vincent/12912>\
**Category:** PyMCon Web Series\
**Created:** [September 15, 2023, 12:49pm UTC](https://discourse.pymc.io/t/new-pymcon-talk-released-bayesian-causal-modeling-by-thomas-wiecki-ben-vincent/12912 "2023-09-15T12:49:52Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![purna135](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/purna135/32/4895_2.png) [@purna135](https://discourse.pymc.io/u/purna135)\
**Post date:** [September 15, 2023, 12:49pm UTC](https://discourse.pymc.io/t/new-pymcon-talk-released-bayesian-causal-modeling-by-thomas-wiecki-ben-vincent/12912/1 "2023-09-15T12:49:52Z")

</div>

[![](https://img.youtube.com/vi/b47wmTdcICE/maxresdefault.jpg "PyMCon Web Series - Bayesian Causal Modeling - Thomas Wiecki") ](https://www.youtube.com/watch?v=b47wmTdcICE)

Welcome to the 10th event of the PyMCon Web Series! As part of this series, most events will have both an asynchronous component and a live Q&A.

**Speaker:** [Thomas Wiecki](https://twiecki.io/), CEO & founder of [PyMC Labs](https://www.pymc-labs.com/).  
**Event type:** Recorded Talk with Live Q&A  
**Q&A Date/Time:** 2023-09-28T13:00:00Z ([subscribe here](https://dashboard.mailerlite.com/forms/241188/73241617305175542/share) for email updates)  
**Register for Q&A:** [Meetup event](https://www.meetup.com/pymc-online-meetup/events/296035699) (to get the Zoom link)  
**Website:** [PyMCon Events · PyMCon Web Series](https://pymcon.com/events/)

**NOTE:** This session is exclusively for Q&A. We kindly request that you watch the recording before joining the event. Plus, The event will be recorded. Subscribe to the [PyMC YouTube channel](https://www.youtube.com/c/PyMCDevelopers) for notifications.

## Abstract of the talk:

Causal analysis is rapidly gaining popularity, but why? Machine learning methods might help us predict what’s going to happen with great accuracy, but what’s the value of that if it doesn’t tell us what to do to achieve a desirable outcome? Without a causal understanding of the world, it’s often impossible to identify which actions lead to a desired outcome.

Causal analysis is often embedded in a frequentist framework, which comes with some well-documented baggage. In this talk, Thomas will present how we can super-charge PyMC for Bayesian Causal Analysis by using a powerful new feature: the do operator.

## Content

**Slides:**

> **[Bayesian Causal Inference](https://docs.google.com/presentation/d/1xRm3eTLumiiLaTCTcKFxfgNxa-_dTnDvxzKUxztq85E/edit)**
>
> Bayesian Causal Inference https://docs.google.com/presentation/d/1BZYXHNWeGJNt7rPudJh6KMnXqatoCDAgQU1d7YckPUU/edit#slide=id.p https://docs.google.com/presentation/d/163bW-Nbu5H6KcgibQdskEKrYkrLccdrcZtIOB99tI8c/edit#slide=id.gdfef06e8da\_0\_16...

**Code:**

> **[Bayesian Causal Inference in Python: Using PyMC's New do-Operator](https://www.pymc-labs.com/blog-posts/causal-analysis-with-pymc-answering-what-if-with-the-new-do-operator)**
>
> Learn how to use Bayesian causal analysis with PyMC and the new do operator to answer 'What If?' questions.

### About the Speaker:

- **[Dr. Thomas Wiecki](https://twiecki.io/)**  
Dr. Thomas Wiecki is an author of PyMC, the leading platform for statistical data science. To help businesses solve some of their trickiest data science problems, he assembled a world-class team of Bayesian modelers and founded PyMC Labs – the Bayesian consultancy. He did his PhD at Brown University, studying cognitive neuroscience.

## Sponsor

We thank our [sponsors](https://pymcon.com/sponsors/) for supporting PyMC and the PyMCon Web Series. If you would like to sponsor us, [contact us](https://pymcon.com/contact/) for more information.

[Adia Lab](https://www.adialab.ae/) is an independent, Abu Dhabi-based laboratory dedicated to basic and applied research in data and computational sciences.  
ADIA Lab focuses on societally-important topics such as climate change and energy transition, blockchain technology, financial inclusion and investing, decision making, automation, cybersecurity, health sciences, education, telecommunications, and space, by conducting cutting-edge research in Data Science, Artificial Intelligence, Machine Learning, and High-Performance Computing.

---

<div class="post-metadata">

**Author:** ![Galen\_Seilis](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/galen_seilis/32/6011_2.png) [@Galen\_Seilis](https://discourse.pymc.io/u/Galen_Seilis)\
**Post date:** [September 28, 2023, 1:09pm UTC](https://discourse.pymc.io/t/new-pymcon-talk-released-bayesian-causal-modeling-by-thomas-wiecki-ben-vincent/12912/2 "2023-09-28T13:09:10Z")

</div>

Does the do-operator in PyMC work with time series? If I intervene on a state at time t, does this propagate through to later states in the model?

---

<div class="post-metadata">

**Author:** ![JAB](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/jab/32/5791_2.png) [@JAB](https://discourse.pymc.io/u/JAB)\
**Post date:** [September 28, 2023, 1:24pm UTC](https://discourse.pymc.io/t/new-pymcon-talk-released-bayesian-causal-modeling-by-thomas-wiecki-ben-vincent/12912/3 "2023-09-28T13:24:14Z")

</div>

In your example, (if I recall correctly) you implemented the `do(z)` operator with a binary variable. How does this change when z is a continuous variable? I believe this may be relevant to your hello fresh example, but I am not sure if I am making the connection.

---

<div class="post-metadata">

**Author:** ![Galen\_Seilis](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/galen_seilis/32/6011_2.png) [@Galen\_Seilis](https://discourse.pymc.io/u/Galen_Seilis)\
**Post date:** [September 28, 2023, 1:36pm UTC](https://discourse.pymc.io/t/new-pymcon-talk-released-bayesian-causal-modeling-by-thomas-wiecki-ben-vincent/12912/4 "2023-09-28T13:36:01Z")

</div>

What changes to Bayesian workflow ([Gelman et al 2020](https://arxiv.org/abs/2011.01808)) should we consider making when we’re also trying to do “causal workflow”?

---

<div class="post-metadata">

**Author:** ![olivares-j](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/olivares-j/32/4660_2.png) [@olivares-j](https://discourse.pymc.io/u/olivares-j)\
**Post date:** [September 28, 2023, 1:42pm UTC](https://discourse.pymc.io/t/new-pymcon-talk-released-bayesian-causal-modeling-by-thomas-wiecki-ben-vincent/12912/5 "2023-09-28T13:42:12Z")

</div>

Hi, super cool talk. I would like to know, When a node is fixed with the do operator into a certain value, What happens with the parent nodes (the ones above in the hierarchy)? Are those sampled from the prior or simple not used in the model anymore? Thanks!

---

<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:** [September 28, 2023, 4:36pm UTC](https://discourse.pymc.io/t/new-pymcon-talk-released-bayesian-causal-modeling-by-thomas-wiecki-ben-vincent/12912/6 "2023-09-28T16:36:16Z")

</div>

> [@Galen\_Seilis](#):
>
> Does the do-operator in PyMC work with time series? If I intervene on a state at time t, does this propagate through to later states in the model?

You would probably need to create a new predictive model to intervene more granularly inside a time-series (so manually, instead of using `do` to do that for you). Something like the forecasting examples in this blogpost: [Out of model predictions with PyMC - PyMC Labs](https://www.pymc-labs.com/blog-posts/out-of-model-predictions-with-pymc/)

---

<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:** [September 28, 2023, 4:38pm UTC](https://discourse.pymc.io/t/new-pymcon-talk-released-bayesian-causal-modeling-by-thomas-wiecki-ben-vincent/12912/7 "2023-09-28T16:38:47Z")

</div>

> [@olivares-j](#):
>
> Hi, super cool talk. I would like to know, When a node is fixed with the do operator into a certain value, What happens with the parent nodes (the ones above in the hierarchy)? Are those sampled from the prior or simple not used in the model anymore? Thanks!

If they are not connected to the likelihood through any other path, then yes, they will be sampled from the prior (in prior and posterior sampling). There is a kwarg in `do` to remove such variables: `prune_vars=True`.

[https://www.pymc.io/projects/docs/en/stable/api/model/transform/generated/pymc.model.transform.conditioning.do.html](https://www.pymc.io/projects/docs/en/stable/api/model/transform/generated/pymc.model.transform.conditioning.do.html)

---

<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:** [September 28, 2023, 4:40pm UTC](https://discourse.pymc.io/t/new-pymcon-talk-released-bayesian-causal-modeling-by-thomas-wiecki-ben-vincent/12912/8 "2023-09-28T16:40:23Z")

</div>

> [@JAB](#):
>
> ow does this change when z is a continuous variable?

The type of variable being intervened upon does not change the process. Do you have a specific concern in mind?

---

<div class="post-metadata">

**Author:** ![JAB](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/jab/32/5791_2.png) [@JAB](https://discourse.pymc.io/u/JAB)\
**Post date:** [September 29, 2023, 1:37pm UTC](https://discourse.pymc.io/t/new-pymcon-talk-released-bayesian-causal-modeling-by-thomas-wiecki-ben-vincent/12912/10 "2023-09-29T13:37:09Z")

</div>

EDIT: I replied to the wrong spot so I am moving it to the correct reply.

Hi Ricardo,

Thomas was able to answer this in the discussion. He pointed out that we get so used to thinking about distributions that we forgot about the concept of point estimates altogether 😆. He pointed out that it does not matter if `z` is discrete or continuous; however, we do need to remember that `do(z)` will be a constant value. That clarified the issue for me.

The second question I asked was more clarification about `do` vs `observe` in time series problems. I was wondering if we can treat `observe` as the `do` operator if we just replace our data with a simulated time series using `observe`. He pointed out that, no, we cannot do that because `observe` just replaces the data while maintaining the graph structure, whereas `do` breaks the graph structure to isolate that point of intervention. That helped clarify the difference between these two operators for me.

Thanks all, this was great!

---

<div class="post-metadata">

**Author:** ![purna135](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/purna135/32/4895_2.png) [@purna135](https://discourse.pymc.io/u/purna135)\
**Post date:** [October 2, 2023, 9:29am UTC](https://discourse.pymc.io/t/new-pymcon-talk-released-bayesian-causal-modeling-by-thomas-wiecki-ben-vincent/12912/11 "2023-10-02T09:29:46Z")

</div>

If you couldn’t attend the live Q&A session, you can watch the recording on YouTube. Here’s the link:

[![](https://img.youtube.com/vi/4Cul2rWLLhM/maxresdefault.jpg "PyMCon Web Series - Bayesian Causal Modeling - Q&A | Thomas Wiecki") ](https://www.youtube.com/watch?v=4Cul2rWLLhM)
