Skip to content
Python code for part 2 of the book Causal Inference, by Miguel Hernán and James Robins
Jupyter Notebook
Branch: master
Clone or download
jrfiedler Merge pull request #3 from pettypychen/master
Alternative method of calculating the expected value of Y when A =90
Latest commit 34cf0e3 Feb 24, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information. fixed typo Feb 22, 2018
chapter11.ipynb Add files via upload Feb 18, 2019
chapter12.ipynb added legend in chapter12 Apr 24, 2018
chapter13.ipynb added notebooks 11-14 Feb 4, 2018
chapter14.ipynb changed a couple variable names Feb 17, 2018
chapter15.ipynb changed wording in a few places Feb 17, 2018
chapter16.ipynb added notebook 16 Feb 12, 2018

Causal Inference Python Code

This repo contains Python code for the book Causal Inference Part II, by Miguel Hernán and James Robins (book site).

The code here roughly corresponds to the Stata, R, or SAS programs found at the book site.

Python dependencies

Required Python packages:

  • numpy
  • pandas
  • statsmodels
  • scipy
  • matplotlib
  • linearmodels
  • tqdm

If you use the Anaconda distribution of Python, you'll have most of those packages already, and you'll only need to install

  • linearmodels
  • tqdm


The data can be obtained from the book site.

The notebooks all assume that the Excel version of the data has been saved in the same directory as the notebooks.


James Fiedler

You can’t perform that action at this time.