Developing a Causal Inference R Package - Back Door Method

1 minute read

Published:

I work a lot on causal inference research in my day-to-day lab work as part of Dr. Park’s group. I wanted to see if I could determine causality in some of the data I was working with using a method I am quite interested in. I develped this R package which implements the backdoor adjustment method for causal inference.

The backdoor adjustment method is a fundamental concept in causal inference.

The backdoor adjustment method involves controlling for confounding variables by conditioning on them in order to eliminate their effects on the causal relationship between the treatment and outcome variables. This can be achieved using various methods, such as regression or propensity score matching.

If we want to know the effect of X on Y and have a set of variables S as the control, then S satisfies the back-door criterion if (i) S blocks every path from X to Y that has an arrow into X (“blocks the back door”), and (ii) no node in S is a descendant of X. Then:

image

Notice that all the items on the right-hand side are observational conditional probabilities, not counterfactuals.

(excerpted from a CMU Statistics Lecture on Causal Inference)

In this package, I use a linear regression model to estimate the conditional distribution of an outcome variable given input causal variables and confounding variables. By controlling for the confounding variables in this way, we are able to estimate the causal effect of the input variables on the outcome variable while minimizing confounding bias.

This tool isn’t perfect, and honestly it’s meant more for my personal use to just see if results I’m getting in lab are making sense. It’s almost like a fact-checker rather than an independent causality-inferring tool.