Correlation & Causation

Plot real measures across countries with r, ρ and a fitted line, draw cases from causal diagrams, and test many pairs with corrections.

2022 · n 111 · r 0.397 · ρ 0.474 · R² 0.16 · slope 1.62 (95% interval 0.907 to 2.33) · p < 0.001
  • Country
  • Least-squares line
100%

Correlation only. Messerli (2012) suggested that cocoa raises a country's laureates; Maurage, Heeren and Pesenti (2013) showed the link fails once other flavanol-rich foods are counted.

Pick an example. In Real data, point at a country to read its values; in Diagrams and Many tests, a new Seed draws a new sample.

Setup
View
Pair
Fit
View

How is Correlation & Causation working for you?

About Correlation & Causation

Statistics
Pearson's r, Spearman's ρ, least squares
Data year
2022
Countries
111, 199 and 176 by pair
Exact values
the correlations each diagram implies

Correlation & Causation plots real measures across countries and asks what a correlation says about cause. Each pair shows Pearson's r (Pearson 1896), Spearman's ρ from ranks (Spearman 1904), R², the least-squares slope with its 95% interval from Student's t, and the p-value, for 2022: cocoa supply against Nobel laureates per 10 million people (FAOSTAT, CC BY 4.0, and the Nobel Prize data, CC0), GDP per person against life expectancy (World Bank, CC BY 4.0) and nitrogen fertilizer against cereal yield (FAOSTAT through Our World in Data). A label says what other evidence shows about cause, with its source.

Diagrams draws cases from four causal diagrams of normal variables (Pearl 2009): a hidden cause of both measures, a common effect that a study selects on, a chain through a third variable, and a direct effect. The readout gives the sample's correlation beside the exact one the diagram implies, and the same after holding the third variable fixed or selecting on it. Holding a hidden cause fixed removes a correlation it made; selecting on a common effect makes one that was not there; holding a step of a chain fixed hides a real effect.

Many tests correlates unrelated random variables in every pair. At a significance level α, a share α of the pairs pass on average with no correction, so 20 variables make 190 pairs and 9.5 false positives at 0.05. Bonferroni's correction tests each pair at α divided by the number of pairs, and Benjamini and Hochberg's (1995) controls the share of false positives among the pairs that pass. Export the plot as a PNG or its data as CSV.

How to use Correlation & Causation

  1. Pick an example. Choose Chocolate and Nobel prizes, Income and life expectancy, Nitrogen and grain yield, Hidden cause, Selection or Twenty unrelated variables. Each sets the view and its settings.
  2. Read the fit. In Real data the readout gives n, r, ρ, R², the slope with its 95% interval and p; point at a country to read its two values. The line under the plot gives the evidence label and its source.
  3. Change the scale. Log x-axis plots x on a logarithmic axis and fits the line to log10 x, so the slope is the change in y for a tenfold x; Spearman's ρ does not change, since ranks do not. Residuals draws each country's distance from the line.
  4. Draw from a diagram. In Diagrams, pick Hidden cause, Selection, Chain or Direct, and set Arrow strength, Effect of X on Y and People. Hold fixed, or Select on C, shows what adjusting for the third variable does; a new Seed draws new cases.
  5. Test many pairs. In Many tests, set Variables, Cases and Significance level, and pick a Correction. Each cell of the matrix is a pair in its correlation's color, and pairs that pass are outlined.
  6. Export. Save a PNG of the plot, or download the points, cases or pairs as CSV. A share link carries every setting.

Frequently asked questions

Does a strong correlation mean one thing causes the other?

No. A correlation can come from a hidden cause of both, from cases selected on a common effect, or from chance across many tests. Across 111 countries cocoa supply and Nobel laureates per person correlate at r = 0.40, yet Maurage, Heeren and Pesenti (2013) showed that the cocoa explanation fails once other flavanol-rich foods are counted.

What is a hidden cause, or confounder?

A variable that causes both measures. In the Hidden cause diagram with arrow strength 0.6, X and Y correlate at exactly 0.36 although neither affects the other, and holding Z fixed brings the correlation to exactly 0.

Why can adjusting for a variable be a mistake?

Because the variable may lie between cause and effect, or be caused by both. In Chain, holding M fixed hides X's real effect on Y. In Selection, keeping only cases with high C links X and Y where there was no link, as Berkson (1946) described for hospital data.

Why does the chocolate example differ from Messerli's?

Messerli (2012) correlated chocolate consumption with laureates. This tool uses FAOSTAT's supply of cocoa beans and products per person in 2022, laureates counted by birth country within today's borders, and countries of at least 5 million people, a model setting, so its r differs. Japan's 31 laureates are left out: FAOSTAT's food balances do not include Japan.

What do Bonferroni and Benjamini-Hochberg do?

They raise the bar when many pairs are tested. With 20 variables there are 190 pairs, and Bonferroni passes a pair only at p ≤ 0.05/190, about 0.00026. Benjamini and Hochberg (1995) sort the p-values and pass the smallest ones that stay under their rank times α divided by the number of pairs, which controls the share of false positives among the pairs that pass.

References

  1. Pearson, K. (1896). Mathematical contributions to the theory of evolution. III. Regression, heredity, and panmixia. Philosophical Transactions of the Royal Society A 187, 253–318.
  2. Spearman, C. (1904). The proof and measurement of association between two things. American Journal of Psychology 15(1), 72–101.
  3. Berkson, J. (1946). Limitations of the application of fourfold table analysis to hospital data. Biometrics Bulletin 2(3), 47–53.
  4. Benjamini, Y., & Hochberg, Y. (1995). Controlling the false discovery rate: a practical and powerful approach to multiple testing. Journal of the Royal Statistical Society B 57(1), 289–300.
  5. Cutler, D., Deaton, A., & Lleras-Muney, A. (2006). The determinants of mortality. Journal of Economic Perspectives 20(3), 97–120.
  6. Pearl, J. (2009). Causality. Cambridge University Press, 2nd ed..
  7. Messerli, F. H. (2012). Chocolate consumption, cognitive function, and Nobel laureates. New England Journal of Medicine 367(16), 1562–1564.
  8. Maurage, P., Heeren, A., & Pesenti, M. (2013). Does chocolate consumption really boost Nobel award chances? The peril of over-interpreting correlations in health studies. Journal of Nutrition 143(6), 931–933.
  9. Johnston, A. E., & Poulton, P. R. (2018). The importance of long-term experiments in agriculture: their management to ensure continued crop production and soil fertility; the Rothamsted experience. European Journal of Soil Science 69(1), 113–125.