# jrfiedler/causal_inference_python_code

Python code for part 2 of the book Causal Inference: What If, by Miguel Hernán and James Robins

Repository: https://github.com/jrfiedler/causal_inference_python_code
Canonical: https://ross.abutalabs.com/products/causal_inference_python_code
Language: Jupyter Notebook
License Family: other
Topics: causality, causal-inference, data-science, python
Last push: 2022-01-08T02:29:18+00:00

## Health v2 (maintenance only)
Score: 32/100 (v2, computed 2026-09-03T02:39:23.370411+00:00)
- activity 0, release rhythm 35, longevity 100
- inputs: {"age_days": 3132, "days_push": 1699, "days_rel": null, "gap_med": null, "n_releases_24m": 0}
- flags: no_releases, no_license
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 1354, forks 413 (observed 2026-08-28T04:04:28.707918+00:00)

## What it is
A collection of Jupyter notebooks implementing the Python code for Part II of the book 'Causal Inference: What If' by Hernán and Robins. It reproduces the book's Stata, R, and SAS analyses using numpy, pandas, statsmodels, and related libraries.

## Use cases
- learn causal inference from the Hernán and Robins book with Python
- replicate book examples like g-formulas and IP weighting in Python
- find Python equivalents of the book's Stata, R, and SAS programs
- study marginal structural models and standardization hands-on
- teach a causal inference course with worked code examples

## When to choose
- you are working through 'Causal Inference: What If' and want Python implementations
- you want reference code for causal inference methods like IP weighting and g-computation
- you prefer notebooks that mirror the book's chapter-by-chapter analyses

## When to avoid
- you need a production causal inference library with APIs and tests
- you need Part I or Part III of the book, which are not covered
- you require a maintained, licensed package for a software project

## Facets
- artifact type: learning-resource
- maturity: maintenance
- function: data-science, machine-learning
- domain: data-science, education, tutorials
- platform: python
- tags: causal-inference, jupyter-notebooks, statistics, epidemiology, book-companion

## Member repositories
- jrfiedler/causal_inference_python_code (main) score 32

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:04:28.707918+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T04:42:02.090541+00:00, confidence not recorded.
  - readme: https://github.com/jrfiedler/causal_inference_python_code (fetched 2026-08-28T04:04:28.707918+00:00, sha 666ced8d1c22)
- Data as of 2026-08-30T08:39:29.467469+00:00.
