Skip to content
Tutorials Center
My learning

Topics

Causal Inference Tutorial

Learn Causal Inference step by step: 37 lessons in 9 chapters with examples, quizzes, diagrams and projects.

Start learning →

of lessons completed

Getting Started

  1. 1 What Is Causal Inference? Learn what causal inference is, how it differs from prediction, why 'what if' questions need special methods, and see your first simulated cause and effect in Python.
  2. 2 Correlation vs Causation Understand why correlation does not imply causation: the three explanations for an association (cause, reverse cause, common cause) with runnable simulations.
  3. 3 Causal Questions and Estimands Learn to turn a vague business or research question into a precise causal estimand: treatment, outcome, population, comparison and time frame, with simple Python examples.
  4. 4 Simulating Causal Data in Python Set up a causal inference workflow in Python: generate data from a known causal story with NumPy and pandas, estimate effects and compare them with the truth.
  5. 5 Randomized Experiments: The Gold Standard Learn why random assignment removes confounding, how to analyze a randomized experiment with a difference in means and confidence interval, and what can still go wrong.

Causality and Confounding

  1. 6 Confounding: The Central Problem Understand confounders, how they bias treatment effect estimates, the direction of the bias, and how adjusting for a measured confounder recovers the truth, with Python.
  2. 7 Simpson's Paradox See why a trend can reverse when data are split into groups, how Simpson's paradox arises from confounding, and why the causal story decides whether to pool or stratify.
  3. 8 Selection Bias and Collider Bias Learn how conditioning on a collider or selecting a sample on an outcome creates fake associations: the 'talent vs looks' example, survivorship and berkson bias, simulated in Python.
  4. 9 Stratification and Standardization Adjust for confounding by comparing like with like: stratify on a confounder, average the stratum effects with the right weights, and compute standardized outcomes in pandas.

Potential Outcomes

  1. 10 The Potential Outcomes Framework Learn the potential outcomes framework: Y(1), Y(0), individual treatment effects, the fundamental problem of causal inference and the role of selection bias, with simulations.
  2. 11 ATE, ATT, ATU and Conditional Effects Define and compute the average treatment effect, the effect on the treated and untreated and conditional effects, see why they differ, and learn which one to report for a decision.
  3. 12 Ignorability, SUTVA and Positivity Learn the key identification assumptions of causal inference: conditional ignorability (exchangeability), positivity (overlap), consistency and SUTVA, with Python checks and violations.
  4. 13 Regression for Causal Effects Use ordinary least squares to estimate causal effects under ignorability: choosing controls, interactions for heterogeneous effects, g-computation and what the treatment coefficient really means.
  5. 14 Randomization Inference and the Bootstrap Quantify uncertainty in causal estimates without formulas: Fisher's permutation test for the sharp null and bootstrap confidence intervals for the ATE, with Python.

Graphs and Identification

  1. 15 Causal DAGs: Drawing Your Assumptions Learn causal directed acyclic graphs: nodes, arrows, paths, chains, forks and colliders, d-separation rules and how a graph encodes what you assume, with Python code to enumerate paths.
  2. 16 The Backdoor Criterion and Adjustment Sets Use the backdoor criterion to pick a valid adjustment set from a causal DAG: block confounding paths, avoid mediators and colliders, and verify the choice by simulation in Python.
  3. 17 Mediators, Direct and Indirect Effects, and Bad Controls Learn what mediators are, how to separate direct and indirect effects, why controlling for post-treatment variables biases results, and the M-bias example, with Python simulations.
  4. 18 Front-Door Adjustment and the do-Operator Understand the do-operator, the difference between seeing and doing, and how front-door adjustment identifies an effect despite an unmeasured confounder, verified by simulation in Python.

Matching and Weighting

  1. 19 Propensity Scores Learn what a propensity score is, how to estimate it with logistic regression, and how stratifying on it removes confounding in observational data, with runnable Python.
  2. 20 Nearest-Neighbor Matching Build matched samples with nearest-neighbor matching on covariates or propensity scores, add calipers, and estimate the effect on the treated (ATT) with runnable Python.
  3. 21 Inverse Probability Weighting Learn inverse probability weighting: build a pseudo-population balanced on covariates, estimate the ATE, stabilize and trim weights, and bootstrap the standard error in Python.
  4. 22 Balance Diagnostics and Overlap Check whether matching or weighting worked: standardized mean differences, love plots as tables, propensity score overlap, effective sample size and what to do when overlap fails.

Instrumental Variables and DiD

  1. 23 Instrumental Variables Understand instrumental variables: the three assumptions, the Wald estimator, what a LATE means, and how an instrument rescues an effect that unmeasured confounding ruins.
  2. 24 Two-Stage Least Squares Implement two-stage least squares from scratch with NumPy: first and second stage, correct standard errors, controls, the first-stage F-statistic and the weak instrument check.
  3. 25 Difference-in-Differences Learn difference-in-differences: the 2x2 design, the parallel trends assumption, the regression form with an interaction term and clustered standard errors, with runnable Python.
  4. 26 Event Studies and Parallel Trends Test the parallel trends assumption with an event study: estimate effects by period relative to treatment, read pre-trends, run placebo tests, and see what a violation looks like.
  5. 27 Regression Discontinuity Learn regression discontinuity design: sharp cutoffs, local linear regression, bandwidth choice, validity checks such as manipulation and covariate smoothness, and fuzzy designs.
  6. 28 Synthetic Control Learn the synthetic control method: build a weighted blend of donor units that mimics one treated unit, estimate the effect after an intervention and test it with placebo runs.

Uplift and Heterogeneous Effects

  1. 29 Heterogeneous Treatment Effects Go beyond the average effect: define the CATE, estimate subgroup effects and interactions in a randomized experiment, and avoid the false discoveries that come from slicing data too many ways.
  2. 30 Meta-Learners (S, T and X) Estimate heterogeneous treatment effects with machine learning using S-, T- and X-learners. Build each from scikit-learn models and compare them against a known true effect.
  3. 31 Uplift Modeling and Evaluation Learn uplift modeling for marketing and retention: the four customer types, building an uplift model from a randomized test, and evaluating it with decile tables and cumulative gain curves.

Practice and Pitfalls

  1. 32 Doubly Robust Estimation Combine an outcome model and a propensity model with the AIPW estimator: it stays consistent if either model is right. Includes cross-fitting and influence-function standard errors.
  2. 33 Sensitivity Analysis for Unmeasured Confounding Ask how strong an unmeasured confounder would have to be to explain away your result: omitted variable bias, bias tables, tipping points and the E-value, with runnable Python.
  3. 34 Common Causal Pitfalls A field guide to causal analysis mistakes: bad controls, collider bias, adjusting for mediators, immortal time, regression to the mean, interference and p-hacking, with simulations.

Projects and Practice

  1. 35 Project: Coupon Targeting with Uplift End-to-end project: analyze a randomized coupon test, check balance, estimate the average effect, train an uplift model, evaluate the targeting policy's profit and write a recommendation.
  2. 36 Project: A Policy Change with Difference-in-Differences Evaluate a regional policy with a panel: build the data, run two-way fixed effects with clustered errors, draw an event study, add placebo and permutation checks, and write the conclusion.
  3. 37 Causal Inference Practice Problems Twelve practice problems on matching, weighting, IV, difference-in-differences, RDD, uplift and pitfalls, with worked solutions and runnable Python to check your answers.