TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Unlock the Power of Causal Inference and Front-door Adjustment: An In-Depth Guide for Data Scientists

A full explanation of causal inference front-door adjustment with examples including all the Python source code

Graham Harrison
TDS Archive
Published in
11 min readFeb 14, 2023

--

Photo by Evelyn Paris on Unsplash

Objective

By the end of this article you will understand the magic of causal inference front-door adjustment that can calculate the effect of an event on an outcome even where there are other factors affecting both that are unmeasured or even unknown and you will have full access to all the Python code.

I have scoured the Internet and many books trying to find a fully working example of the front-door formula in Python and I have drawn a blank, so unless there are sources out there that I have missed, what you are about to read is genuinely unique …

Introduction

In a recent article I explored the power of the backdoor adjustment formula to calculate the true effect of an event on an outcome even if there are observable factors that are “confounding” both …

The aim was to establish the true effect of taking a drug on patient recovery rates and the magic of the backdoor adjustment formula recovered this effect even though “male” was obscuring that result because -

  • A higher proportion of males took the drug compared to females
  • Males had a higher recovery rate than females
Image by Author

In this example “male” is a “confounder” but the values for “male” were included in the observation data and then the back door formula was applied to prove that the drug trial was having a positive impact.

But what if the “confounder” could not be measured and was not included in the data?

A Real World Example

--

--

TDS Archive
TDS Archive

Published in TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Graham Harrison
Graham Harrison

Written by Graham Harrison

Click here to subscribe to Medium - https://grahamharrison-86487.medium.com/membership - you will get full access to 1000's of articles and support the writers!

Responses (1)