# Causation, Correlation, and Confounding: A Graphical Explainer

I’ve developed a new type of graphic to illustrate causation, correlation, and confounding. It provides an intuitive understanding of why we observe correlation without causation and how it's possible to have *causation without correlation*. I then cover some advanced topics towards the end of the post on heterogeneous treatment effects and SUTVA violations—topics at the frontier of econometrics research. Let's get started!

Causation
=========

Suppose Alice just caught a cold. She read online that taking vitamin C might reduce the time it takes for her to recover,[^1fhx7gvqqtq] so she takes a vitamin C pill and feels better after three days. We’ll denote this as a circle on the graph:

![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXdf2ueo5O9FfWpv7-henwNHJbXsqwNy38JrTJTecMRzpazW51vNCQzzVa6emtYscfZaBfcgdQVYmaE4fd9oPYnAJl81JUp8XjBpY9FJ1ZPs9rWnUEw_YoiexdSSEAifHLrfncN0dg?key=H3F2mqzw9yqptyaOYhhLfw)

Is this enough to tell if vitamin C helped Alice get better? No. We need to know how long it *would’ve* taken Alice to recover if she had not taken vitamin C. Suppose that vitamin C works: it would’ve taken Alice four days to recover without the pill. We can denote that as an x on the graph.

![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXcaE6-3EMgGBo6pLLCTvS1YqpEPMsgFONYvOMDEuuwhlLpc8iUvDFIgDqZps4LAS5s0ajbE7MJ94d0yfI0kCuoMzG_i_7SdNwBphpGpo7ef4H7nq1dod3XopvyCIBkkLVR3D20B?key=H3F2mqzw9yqptyaOYhhLfw)

It’s also possible that taking the pill did not help Alice at all. In other words, she would’ve gotten better in three days whether she took a pill or not. We can illustrate this graphically:

![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXfyw1gQA_Q5ZEeY0hDNJr043q-sDQFh014z3b3onxcqqVe5xUNyk5pJSr30ThvrgcOikDeLuIXg5x12mTfKkh3V4GWC81lq3R9KLzOqVOg50ZwrU0oXKlr12Uyou3HnzgCCumcuVg?key=H3F2mqzw9yqptyaOYhhLfw)

We’ll introduce some terms from the language of causal inference.[^p5rhhzlq9nh] The person with the cold (Alice) is our unit of observation. The number of days it takes her to recover is our outcome variable—the thing we want to affect. The vitamin C pill is our treatment, an action a unit can take. The symbols **o** and **x** represent potential outcomes. In our example, the potential outcomes are the two possibilities: the number of days it takes to recover *with* the vitamin C pill, and the number of days it takes to recover *without* it.

Armed with these new words, we can now define causality:

**Causality: **The *causal effect *(or treatment effect) of a treatment is the *difference* between the potential outcomes.

![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXeWS7AwuNs3y1M2l1ca9Ad0UPXsWJ2eAv2FvhNvX1CZPqXfMiyymkxQMqNHRMQhvRYQz8O91qpAcX4AUwx1mACfMi6b6pSB5ZVZz65TZCKdVxloZ2mmkjyvGqGfrHkox-aJ9eZkXQ?key=H3F2mqzw9yqptyaOYhhLfw)

However, for any given person, we can never observe both potential outcomes. Alice either takes the pill or she doesn’t. This means we cannot directly calculate the causal effect for her. This unobservability is called the **fundamental problem of causal inference**.

Correlation
===========

Let’s now consider four people who all got the cold: Alice, Bob, Carol, and Dan. In this scenario, they are all identical: they will recover in three days if they take vitamin C, and recover in four days if they don’t:

![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXerhnOexh5N2dtCs5rK4qReGfGcw7GtBOHP8P9flPgmVnMyK-MrKwvZC5qazX5IOq6g4tMQZa-gnKQ5dmm6V62kimF3Hkl6RY3OR3VZHnHYia-2a1tmOhfDdnYOJZLN2yq8p78WXA?key=H3F2mqzw9yqptyaOYhhLfw)

Suppose Alice and Bob took the pill, but Carol and Dan didn’t. Here are the data points we can actually observe:

![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXdZwDptI9VBPfRy0r6jOq0IwI54JDiCuundkWEASuzsZxOeGmzED61-K4BfoaJldmfj4NIcS8pLGynGVrOxRfs151jKzEGSzuOGh39_HydGdJ9XlLIlB9Kcj4NZdRZnOEPyTzuhLA?key=H3F2mqzw9yqptyaOYhhLfw)

We observe that the people who took the pill got better after three days, and those who didn’t got better after four days. This means that the pill is *correlated *with people getting better sooner.

**Correlation:** Correlation is calculated using the observed relationship between two variables in the data. 

Notice the key distinction between correlation and causation: correlation is something we can observe, while causation is focused on the difference between potential outcomes that are neverfully observed. However, everyone has identical potential outcomes in this scenario, and the only difference is that Alice and Bob took the pill while Carol and Dan didn’t. In this case, the observed correlation is exactly the causal relationship. 

Confounding
===========

In our previous example, everyone had identical potential outcomes, and the true causal effect was the same as the observed differences. Now, suppose there are two types of people, those who took the flu shot, and those who didn’t. The flu shot reduces the length of someone’s cold by two days, regardless of whether they take a vitamin C pill. In our example, Alice and Bob took the shots, and here are the new potential outcomes:

![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXdQKU8OBf2o61dw-MD212EXLJtvjofU2IiSEpc6IxMN-PFMHANDJ0T4GA9-tudGXRHrBKiYDUfTXmFmoQcdA7WTUexAY410g8r9SxvNr9rOTs6R3WNQpAwZzVl2xn1pYoOCuZEecQ?key=H3F2mqzw9yqptyaOYhhLfw)

Now suppose that Alice and Bob, feeling invincible from their shot, decided to not bother taking vitamin C after they got the cold. Carol and Dan, regretting the laziness of their earlier selves, take a pill after getting the cold. This is the data we observe:

![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXcFIzT3494nFdj6vK3rw94iuybLVx4KBnJv4XxP1avapVex6cyCHrLP46FX6Vcy2cN5OTVzQDqKLFBi5uT8a48dCy1ZdoLfrVuwIzOy50HiUotF_SetoOzrKM1NDjDr3o4upnyU-g?key=H3F2mqzw9yqptyaOYhhLfw)

According to the observed data, those who had vitamin C actually took one day *longer *to recover from the cold! The correlationbetween taking the pill actually has the opposite sign as the causal effect. Let’s take a look at the previous graphic again, but this time with the unobserved potential outcomes in grey:

![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/8db2b61bc855e822f673e383e863db07705e78f77d44fb2d.png)

This happened because the people who took the pill (Carol and Dan) had different potential outcomes than the people who didn’t (Alice and Bob). The **selection effect** is the difference in baseline health between the groups. More formally, it’s the difference in recovery time *without vitamin C* between those who chose to take the pill and those who did not.

To put it another way:

*   The **causal effect** is the difference in potential outcomes *within* a single unit (e.g., Alice with the pill vs. Alice without).
*   The **selection effect** is the difference in potential outcomes *between* treated and untreated units (e.g., Carol's baseline vs. Alice's baseline).

**Confounding: **Confounding happens when there is a selection effect. That is, the potential outcomes of treated units are different from the potential outcomes of untreated units. In our specific example, taking the pill is confounded with whether someone took the flu shot.

Now I’ll show a few more examples of how the causal effect could be different from the correlation we observe. 

Correlation without causation
-----------------------------

We’ll start by showing an example of correlation without causation. Suppose that vitamin C pills have no effect on how long someone’s cold lasts. o and x are in the same place. We’ll still have Alice and Bob take the flu shot. Here are all of the potential outcomes:

![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXeNeDzpnR3qiV2Zal5GyKlndcZ6zlgXfN7bVSFDzdQejIfAUDythgc00wrFXvWdoyqpd_XNheOV4wDuRrvgL8YeuudsAGTp81GqjhvMYjCclgUMsw7W_bMz7LoFcJxz8Qbm9shJ?key=H3F2mqzw9yqptyaOYhhLfw)

In this scenario, we’ll suppose that Alice and Bob are very health-conscious individuals. They always make sure that they are up to date on vaccines and pay close attention to their health. So here, Alice and Bob take vitamin C, while Carol and Dan do not. (This is the opposite of the selection that occurred in the previous example). We observe the following data:

![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXejXeFluhZMZjsC0_N8SsFaEE3CpxPn4Aw0CdyhMIvRCWEE2vVwkWV_yWw_QWtcnt9qzm2Csg_DKLO8oZjNIpIizXyB22a-tvoVyXdr-VIMayllPa3N9KPGf5hYLqgGC8D9jLr1?key=H3F2mqzw9yqptyaOYhhLfw)

Because of confounding, those who took vitamin C took two fewer days to recover from the cold, even though vitamin C had no causal effect on how long it took for them to recover. 

We have empirical evidence that stories like this—where health-conscious individuals select into treatments with zero causal effects—play out in real life. In the early 1990s, there were some studies showing that vitamin E supplements are good for you. This led to a large increase in vitamin E sales until 2005 when updated studies from randomized trials showed that vitamin E actually has no (or even a negative) effect on health. 

[Oster (2020)](https://pubs.aeaweb.org/doi/pdfplus/10.1257/aeri.20190355) found that between 1990 and 2005, people who took vitamin E had 25% lower mortality, while after 2005 vitamin E users only had 10% lower mortality. People who took vitamin E supplements were also, for example, much less likely to smoke. This suggests that many people who already had healthy lifestyles started taking vitamin E (which had little causal effect on their health), leading to a large observed correlation between vitamin E *use* and health outcomes. 

Importantly, the correlation between vitamin E and health remains statistically significant even after we control for various observable outcomes, such as education, income, smoking habits, exercise, vegetable consumption, and more. This suggests that there are *unobservable *differences between those who took vitamin E and those who didn’t which led to the observed statistical relationship.[^79n2vdi44fd] 

Causation without correlation
-----------------------------

“Correlation does not equal causation” is something people often say. But does causation imply that things have to be correlated? No. We can demonstrate this with a simple modification to our first example in the confounding section. Now, taking the flu shots only reduces the time it takes to recover by one day. Here are our potential outcomes:

![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXfpJMO0RbXkR1AEQBuWEL9OELaclVXK90rMi_Ps7fa9P917kozuzqrdkVmqrLzSJ4_cLV_3oI16AAHUh-H7B8xSzXx1VylJFHdOlIl885R7rj5jtRDZZN2nov-Mus9FpwRlbWEn?key=H3F2mqzw9yqptyaOYhhLfw)

Following the first example, Alice and Bob do not take the vitamin C pill while Carol and Dan do. We observe that everyone took three days to recover from the cold, regardless of whether they took a pill or not. In this case, the selection effect and causal effect cancel each other out exactly:

![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXd4UktDCjHcnsgL917lLGqBhSO4i1rJoi1wsI4juAvy73f-PLXzk11RvC5GoRGNaC2INBkePRPPyVBLfbUt5YKq7LHCsynUuWAfCgns6SmBGPo2kJwAZFQIgrxDz7Cdt1ypUab0Dg?key=H3F2mqzw9yqptyaOYhhLfw)

This example may seem unnatural, but causation without correlation is common in control systems where the treatment is selectively applied to keep something constant. For example, consider how much power an air conditioner uses and the temperature inside a climate-controlled room. Turning the AC power up decreases the temperature, which is naturally cooler at night.

![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXfeohQwXNMcV1YRiY3gT037rekgkEAnuo80EOPBU22zEfO06qDrFFKs1mhvxVejsEXCAs-yjS7sIL9d7MT3-tQ-FR40_mW0UxrSbwSwLwpxOArbVBcOkH-jCWzL-8glf3k4D58D?key=H3F2mqzw9yqptyaOYhhLfw)

If we set the AC to 23°C, it’ll alternate between high and low power, and we’ll observe zero correlation between AC power and the temperature in a room, even though higher power causes the temperature in a room to drop. 

![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXfPmwqZ_82wIhlNBCyx8tnDIBQeb4DPObuUNuaJjuMECWUas7W7PqfhXZqZRpezRou094DjQ4bwbSjZgv0sSKEGB7NMKJc_MLZ6dOXhj6pSPu9UxjdV0LPMR1swWHSVDiReHgMk?key=H3F2mqzw9yqptyaOYhhLfw)

Why we randomize
================

The fundamental problem in causal inference is that we can never observe more than one potential outcome for every unit, yet the value we’re trying to find–the causal effect–is defined in terms of the difference in potential outcomes. If we randomize who receives the vitamin C pill in a large sample, then the people who got the flu shot and those who didn't will be distributed roughly evenly across the "treatment" and "control" groups. As a result, the two groups become comparable.

Suppose we have many people who got a cold; some took a flu shot, and some didn’t. Below are their potential outcomes: (I’ve added some noise so they all take slightly different amounts of time to recover)

![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXcLi05KJ1dJvVNYRKRn4vrKMlx3rMHSnrmMVmVvJvL2EYMowB86z4PRoj5tS5SvrV17rjNJ19Brw3gEXdsP6LMwkwqlq8cEONvEecfxVWTEE7uYaXGbKP3--Qu37WDoGUqhaVZKKw?key=H3F2mqzw9yqptyaOYhhLfw)

If we randomize, then about the same number of people get the pill in both groups, as seen in the graph below:

![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXeWEvHjRNKKqWztMFmnjc_9QNdpoBrjPXiau8lEXS8geDu8m0R3UmuRyx2u8ZzP8u3MJH0SYJrVc8dBbTRgwY6G_RLXpRhislY-P4_IJ0wwLtd5eNcgZLE4hEChjVkvp7E6wQo7lg?key=H3F2mqzw9yqptyaOYhhLfw)

As a result, there is zero selection effect. The observed difference in those who took vitamin C and those who didn’t reveal the true causal effect of the vitamin C pill. I plot the distributions in dot plots below: you can see that there are two modes for people who took/didn't take the flu shot.

![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXefH1RPclLvyEig-5uTEaezaUEXwsJFs9BBm6Qnn7ruNFYa0kwSV0IQ7puXMP7i21_055A5rUtnTtGzG9PUxxLJPOFWh3TKU7aVeXAQZqLi8kVAfgVLi4JyXYighYQqRDJXz49uwQ?key=H3F2mqzw9yqptyaOYhhLfw)

Absent experimental data, economists use various other methods to get as close as we can to the experimental ideal. [Causal Inference: The Mixtape](https://mixtape.scunning.com/) is a good reference if people are interested in learning more. A particularly cool [recent paper](https://www.nber.org/papers/w33817) tries to directly estimate the selection effect by comparing correlations in observational data with the correlation in randomized experiments.

Advanced Topic: Heterogeneous treatment effect estimation and targeting
=======================================================================

In our previous examples, the effect of our treatment is the same for everyone. However, this might not always be the case. Suppose that the vitamin C pill works much better if you haven’t already taken a flu shot and reduces the length of your cold by 1.5 days, while if you took a flu shot already, the effect is only 0.5 days.

![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXfeeV3VJVK9B3n1HtL1YajvxCk_J1DTjL2JRc_8_8eA2bJfBqew4bxQfyuPmMG3vZdrVZdkvVvuzNFSqQgZy1BqGyQ1Xl916d_dup-LNdN_MLRXUmcP1ffUmnKGwRYlffkGAbIX?key=H3F2mqzw9yqptyaOYhhLfw)

As long as our sample is large and we randomize, we’re likely to get subgroup balance. That is, in any arbitrary subgroup, around half the people would randomly receive the treatment, while half wouldn’t (in reality, we often ensure this by doing block randomization).

![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXdJ8Otj0r9vIm1Mz2We0bu6q7Z5KoRToo_mkWR_FCNqagH9JxgBOgpsu672oWfEGwKtmYn0-Fzd7Oit9taL1EncXq5fuutQ5gpZsWQgQNGksvFJt7dx4JJAc44MGDOPMfoHi0EDhw?key=H3F2mqzw9yqptyaOYhhLfw)

Instead of calculating the average treatment effect by computing the mean days it takes to recover from the cold for those who took the pill and the mean for those who didn’t, we calculate the mean separately for those who took the flu shot and those who didn’t. This gives us the *conditional average treatment effect *or CATE, which is different from the average treatment effect (ATE) for everyone.

![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXcrvJjEu_SElaMbw8qmmUOZBoCPBXMnWBvKQECiAoGRUAZ3IWHlKjaVpZUzg8T15e1vJgglNbMe8Ukxc1xo8qffRc-oH-Z6wE73uOwC0lIsKvatbTpqchW9zb4B46rRlBJefPQq6w?key=H3F2mqzw9yqptyaOYhhLfw)

This is the logic behind prioritizing COVID-19 vaccines to vulnerable groups: the treatment effect of the COVID-19 vaccine is larger among some groups compared to others.

In modern-day econometrics, researchers apply machine learning methods to algorithmically discover which subgroups where the treatment effect of an intervention is the largest. In fact, given lots of information on someone’s characteristics, these ML algorithms can predict the treatment effect for an individual–something we could never directly observe. Combined with information on the cost of treatments, causal ML methods allow us to better target our treatment to units where it is the most efficient. This is a lot of what I did when I worked as an economist at Walmart. If you’re interested in learning more, I recommend [Susan Athey’s Stanford class,](https://www.youtube.com/watch?v=Z0ZcsxI-HTs&list=PLxq_lXOUlvQAoWZEqhRqHNezS30lI49G-) as well as the paper [Treatment Allocation Under Uncertain Costs](https://arxiv.org/abs/2103.11066).

Advanced Topic: SUTVA violation and spillover effects
=====================================================

This one is hard to illustrate graphically, but I want to mention it here for completeness. In previous examples, the potential outcomes of a treated unit depend only on its own treatment status and not the treatment status of others: how long it takes for me to recover from the cold doesn’t depend on if someone *else* took a vitamin C pill. This is called the stable unit treatment value assumption (SUTVA). 

This assumption often does not hold when there are interactions between units. For example, the causal effect of a COVID-19 vaccine on my health depends on whether others around me are vaccinated. If everyone else is vaccinated, then the level of COVID-19 is low. Thus, I’m unlikely to get COVID-19, and the expected effect of the vaccine is low. Similarly, if I get vaccinated from COVID-19, it also helps improve the health outcomes of everyone around me (in expectation).

I'm personally not as familiar with this literature, but those interested in learning more could probably start with [Average Direct and Indirect Effects Under Interference](https://arxiv.org/abs/2104.03802) and [Treatment Effects Under Market Equilibrium](https://arxiv.org/abs/2109.11647).

Conclusion
==========

When we make decisions, we're concerned with cause and effect. To measure causality, we need to know not just what *is*, but what *could be*. As we've seen, the core challenge is that we only get to observe one potential outcome and can never simultaneously observe the road taken and the one not taken.

In this post, I introduce a new type of chart to illustrate these potential outcomes. I then use the chart to define causation, correlation, and confounding. Through various examples, I show that correlation does not equal causation and causation does not imply correlation. The charts illustrate how randomized assignment with a large sample minimizes selection effects and helps us recover the causal effect. Finally, I cover two advanced topics: heterogeneous treatment effects and SUTVA violations. 

As Alice, Bob, Carol, and Dan recover from their cold, they ponder what could've happen in a different world, where they made different decisions. 

"What if we all did the exact opposite?" muses Alice, still sniffling slightly. "Would I have recovered in three days without vitamin C?"

"And would I have recovered in two days if I'd taken it?" adds Carol, who's feeling much better now.

Bob sits in the corner, sketching o's and x's on his Walmart receipt for [Spring Valley Vitamin C Supplement with Rose Hips Tablets, 500 mg, 100 Count](https://www.walmart.com/ip/Spring-Valley-Vitamin-C-Supplement-with-Rose-Hips-Tablets-500-mg-100-Count/6139509340?classType=REGULAR&athbdg=L1102&from=/search). "You know what the weirdest part is?" he finally says. "Even if the vitamin C did absolutely nothing, I'll probably take it again next time. [Just in case](https://www.astralcodexten.com/p/covidvitamin-d-much-more-than-you)."

*Acknowledgements: Thanks for feedback from Amanda Gregg, Bill Zhang, Jack Zhang, Jasmine Cui, Joseph Campbell, participants at* [*Less Online*](https://less.online/)*, and my younger brother. Claude 4 Opus coded up the graphics for plots with many units (both o4-mini and Gemini 2.5 Pro gave confused responses). Gemini 2.5 Pro and Claude 4 Opus helped with editing. *

[^1fhx7gvqqtq]: See here 

[^p5rhhzlq9nh]:  I’m mostly drawing from causal inference language used by economists, which seems to be pretty distinct from how computer scientists talk about causality.  

[^79n2vdi44fd]: These unobservable confounders are everywhere, and they're especially present when you're comparing people who chose to do something with people who didn't choose to do the thing. I claim that this means you should generally ignore causal conclusions from studies that merely control for observable differences between treated or untreated groups (e.g., that one study on the effect of HRT, almost all studies in nutrition, etc.).