Causal Inference & DAGs

Brendan & Bella

2026-08-17

This workshop is plagiarism!!

  • almost all of this content comes from Statistical Rethinking, a textbook and online course that is completely free and available by Richard McElreath
  • a good portion also comes from The Book of Why and other works by Judea Pearl
  • there are many scholars, ecologists and otherwise who use this method and explain it better than I ever will - resources at the end

Let’s not panic

  • the beauty of causal inference is that it relies on concepts that come very naturally to the human brain and is founded on using the expert scientific knowledge that every scientist brings to their studies

  • THIS DOES NOT CHANGE EVERYTHING - just gives you a framework to easily express what you already feel and know

Why don’t we talk / learn about causation?

  • Pearson & Galton, founders of modern statistics, failed in creating the tools needed for causal inference and subsequently decided that it was impossible and “unscientific”

    • they used their enormous influence to teach generations of scientists this and attack anyone who opposed them
  • Judea Pearl invented the math required to answer causal questions only ~ 40 years ago! Science is slow!

  • causation is not controversial - we are just transitioning

What is causal inference?

  • the study of causes and effects: association, intervention, and counterfactuals
  • hypothesis testing
  • effect sizes, direction of effects, comparisons between groups, probability distributions, interventions, etc.
  • agnostic of statistical approach (i.e., Bayesian or frequentist)

Judea Pearl’s Book of Why

What is causal inference NOT?

  • prediction!! forecasting!!

  • if we want to use our models to estimate data in places or times that we do not have data for, but we DO NOT CARE about the relationships between the things in our model, that is prediction and not causal inference

  • prediction is cool!! it is separate from (and mathematically at odds with) causal inference

  • AIC is a tool for measuring the predictive power of your model - it is not appropriate for causal inference

  • NOTE: causation vs prediction is a difference in approach and philosophy, but there is overlap in tools (e.g., you may use a “predict” function in R to generate a causal effect size)

A causal workflow

  1. read the literature, develop hypotheses and understanding of the system

  2. develop research question(s) of interest

  3. build a DAG** representing the system (step repeated many times after discussions with collaborators, co-authors, etc)

  4. identify data required to answer questions of interest

  5. collect data

  6. build statistical models to test question

  7. report DAG + results

DAGs : a tool for causal inference

  • “directed acyclic graph” - relationships go in one direction

  • arrows indicate a causal relationship from one variable to another

  • use your expert knowledge + literature to outline your system with your hypotheses and assumptions (you already make assumptions now, you just don’t visualize them!)

  • decide what variables you need in your statistical test (e.g., model) using your DAG

Why do DAGs matter?

  • putting everything in your model does not test the relationship(s) you are interested in
  • complex systems have confounders that mislead us and that we need to adjust for
  • adjustments are dependent on our DAG and the variable of interest

Statistical Rethinking, Lecture 5

Example: question of interest

!!! I am not a mammologist !!!

  1. What is the effect of anthropogenic disturbance on snowshoe hare abundance?
  2. What disturbance type has the biggest impact on snowshoe hare abundance?

Example: building the DAG

Example: identifying the adjustment set

Q1: What is the effect of anthropogenic disturbance on snowshoe hare abundance?

Example: building a model

  • my “adjustment set” indicates what variables I need to add to my model to answer my question
  • pay attention to total effect vs direct effect
  • you can only interpret the “exposure” (e.g., independent variable) that you have adjusted for
mod <- lm(abundance ~ intensity : type, data = snowshoe_hare)
  • NOTE: interactions are not explicitly included in adjustment sets

Example: asking another question

Q2: What are the effects of different disturbance types?

mod2 <- lm(abundance ~ type, data = snowshoe_hare)

Example: my model fit is bad???

  • you can add other variables to your model that improve model fit (e.g., season or site), if they are not confounders aka your model is still correctly adjusted
  • cannot interpret these effects

Table 2 fallacy

Some DAG notes / a petit sermon

  1. variables that do not have shared causes in your system do not need to be included - your DAG does not need to include every variable in the world

  2. do NOT exclude variables just because you haven’t measured them, these are still potential confounders and need to be part of your DAG!

  3. Metrics =/= causes, use the process/mechanism and not the metric that you measure (e.g., veg abundance causes a difference in temperature, not NDVI)

  4. you are an expert with good intuition and expertise, don’t be scared to put your assumptions down on paper

  5. presenting the assumptions you are making about your system is good, transparent science and allows the development of the field

    • !! you are doing this anyways !! when you decide what variables to collect / what to include in your models, you are just being less transparent about it! we must always do our best and be brave!

Let’s build (& share) our own DAGs

dagitty

  • 10 mins to build a DAG for your system
  • someone (or multiple people) shares their DAG
    • we go through it
    • we adjust the DAG to answer a research question

Resources