liveBook · Manning

Spurious correlation

As explained in Causal Inference for Data Science

A spurious correlation is a statistical association between variables that does not reflect a causal relationship between them.

A spurious correlation is a statistical association that does not represent a causal relationship. Two variables may move together because a third factor affects both, so prediction alone cannot establish what would happen after an intervention. section 1.2

Population, revenue, and doctorates

A synthetic dataset generates population first, then makes arcade revenue and computer-science doctorates depend on population independently. Revenue and doctorates nevertheless show a correlation of 0.95. The association is strong, but it does not by itself prove that population is the actual explanation in a real setting. section 1.4.1

When image backgrounds mislead a classifier

If training images commonly show dogs against green backgrounds and fish against blue ones, a classifier may learn the background rather than the animal. A dog jumping against blue may then be predicted as a fish because the model exploits a spurious correlation. section 4.3.3

Use the concept to separate predictive success from causal understanding:

  • Treat a high correlation or accurate prediction as evidence of association, not proof that changing one variable will change the other. section 1.2
  • Use synthetic data to test whether an apparent relationship can arise from a hidden data-generating process. section 1.4.1
  • Consider confounders, assumptions, goals, and limitations before drawing causal conclusions. section 1.2
Listing 1.1 (R) Building a synthetic dataset that creates spurious correlations
set.seed(1234)

time <- 2000:2009
population <- 280 + 3 * (time - 2000) +
    rnorm(n=length(time), sd=0.1)  #1
revenue <- 1.25 + (population - 280) * 0.015 +
    rnorm(n=length(time), sd=0.05)  #2
)
doctorates <- 700 + (population - 280) * 30 +
    rnorm(n=length(time), sd=10)  #3

cor(doctorates, revenue)

Run the R listing to generate population, revenue, and doctorate variables and inspect the resulting correlation. section 1.4.1

How Causal Inference for Data Science covers it

How deep it goes
Defines the association, demonstrates a hidden third factor, and shows a model failure, but stops short of formal causal-identification procedures.
Examples
Uses synthetic population data, arcade revenue, computer-science doctorates, and animal-image backgrounds to expose misleading associations.
What you can do after
Diagnose misleading associations by separating predictive accuracy from causal evidence and testing alternative data-generating explanations.
How it connects
Connects spurious correlation with causal inference, confounders, interventions, predictive modeling, and machine learning.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Causal Inference for Data Science. The section links point to the parts of the book it draws on.