Module 13

Correlation

Measuring relationships between variables

Correlation Fundamentals

  • 01

    Pearson r

    Linear correlation coefficient

  • 02

    Direction & Strength

    Interpreting correlation values

  • 03

    Spearman ρ

    Rank-based correlation

  • 04

    Limitations

    What correlation doesn't tell you

01

Pearson Correlation

Measuring Linear Relationship

r ≈ +0.95 (strong positive)

Pearson's r measures the strength and direction of a LINEAR relationship between two continuous variables. It ranges from -1 (perfect negative) to +1 (perfect positive), with 0 meaning no linear relationship.

How r is Calculated

r = Σ[(xᵢ - x̄)(yᵢ - ȳ)] / [(n-1) · sₓ · sᵧ]
Numerator:
Sum of cross-products of deviations
Denominator:
Product of standard deviations

The formula standardizes the covariance between X and Y. When X is above its mean and Y is above its mean (or both below), the product is positive, contributing to positive r.

Understanding r Values

-1.0-0.50+0.5+1.0
|r| = 0.0 - 0.1Negligible
|r| = 0.1 - 0.3Weak
|r| = 0.3 - 0.5Moderate
|r| = 0.5 - 0.7Strong
|r| = 0.7 - 1.0Very Strong

The magnitude |r| indicates strength regardless of direction. These benchmarks are guidelines—context matters. In some fields, r = 0.3 is considered strong.

Coefficient of Determination

r = 0.7
Correlation
→
r² = 0.49
Explained variance
r² = 0.49 means X explains 49% of the variance in Y. The other 51% is due to other factors or random variation.

r² (r-squared) is the proportion of variance in Y explained by X. If r = 0.7, then r² = 0.49, meaning X accounts for 49% of Y's variability. This is often more meaningful than r itself.

02

Direction & Strength

Positive Correlation

As X increases, Y increases
Examples: Height & weight, study time & grades, income & spending

Positive correlation: both variables move in the same direction. When one goes up, the other tends to go up too. Higher X values are associated with higher Y values.

Negative Correlation

As X increases, Y decreases
Examples: Price & demand, exercise & body fat, age & reaction time

Negative correlation: variables move in opposite directions. When one goes up, the other tends to go down. Higher X values are associated with lower Y values.

No Correlation

No LINEAR pattern between X and Y
Warning: r ≈ 0 doesn't mean no relationship—could be non-linear!

r ≈ 0 means no LINEAR relationship. The scatter has no upward or downward trend. But beware: there could still be a strong NON-LINEAR relationship that r won't detect.

Comparing Strengths

r = 1.0
Perfect
r ≈ 0.8
Strong
r ≈ 0.4
Moderate

Strength shows how tightly points cluster around the trend line. Perfect correlation (r = ±1) has all points exactly on a line. Weaker correlations have more scatter.

03

Spearman Correlation

Rank-Based Correlation

Original Values
X: 2, 5, 8, 15, 50
Y: 10, 20, 25, 40, 100
Converted to Ranks
X: 1, 2, 3, 4, 5
Y: 1, 2, 3, 4, 5
Then calculate Pearson r on the ranks

Spearman's ρ (rho) converts values to ranks, then calculates Pearson r on those ranks. It measures monotonic relationships (consistently increasing or decreasing), not just linear ones.

Spearman vs Pearson

Use Pearson r When:
• Both variables continuous
• Relationship is linear
• No extreme outliers
• Data approximately normal
Use Spearman ρ When:
• Ordinal data
• Non-linear monotonic relationship
• Outliers present
• Non-normal distributions

Spearman is more robust than Pearson. It works with ordinal data, handles outliers better, and captures monotonic non-linear relationships. Use it when Pearson's assumptions are violated.

Capturing Monotonic Relationships

Pearson r ≈ 0.85Spearman ρ ≈ 0.99
Curved but monotonically increasing

This relationship is curved (non-linear) but monotonic (always increasing). Pearson underestimates it because it's not a straight line. Spearman captures it perfectly because ranks preserve order.

04

Correlation Pitfalls

Correlation ≠ Causation

🚨 The #1 Statistical Mistake
Ice cream sales correlate with drowning deaths.
Does ice cream cause drowning? NO!
Hidden variable: Hot weather
Both increase in summer. The correlation is real, but there's no causal link between them.

Correlation shows association, NOT causation. Two variables can correlate because: (1) X causes Y, (2) Y causes X, (3) a third variable causes both, or (4) pure coincidence. Never assume causation from correlation alone.

Outlier Sensitivity

Without Outlier
r = 0.02
With Outlier
r = 0.75

One outlier can dramatically change r. Always visualize your data with a scatter plot before trusting a correlation coefficient. A single extreme point can create or destroy a correlation.

Range Restriction

Restricted range: r = 0.4Full range: r = 0.9

If your sample has a restricted range on X or Y, correlation will be underestimated. Studying only top students? You'll find weaker SAT-GPA correlation than in the full population.

Non-Linear Relationships

r ≈ 0 but STRONG relationship!

Pearson r = 0 for this U-shaped pattern, yet there's clearly a strong relationship. Correlation only measures LINEAR association. Always visualize data—non-linear patterns can have r ≈ 0.

Interactive Correlation Explorer

Correlation Explorer
Click to add points
r = 0.00
Add points to calculate

Click on the canvas to add points and watch the correlation coefficient (r) update in real time. Try the preset buttons to see how different patterns produce different correlations. Notice that the non-linear pattern has r ≈ 0 even though there's a clear relationship!

★

Real-World Examples

Apply your knowledge to practical scenarios

01

The Ice Cream and Drowning Paradox

A news report claims: 'Ice cream sales strongly correlate with drowning deaths (r = 0.85). Should we ban ice cream to save lives?'

Q What does the correlation r = 0.85 actually tell us? +
A It tells us that when ice cream sales are high, drowning deaths also tend to be high. It says NOTHING about whether one causes the other.
Q What's the hidden 'third variable' explaining both? +
A Summer weather! Hot temperatures increase both ice cream consumption AND swimming (leading to more drownings). Temperature is the confounding variable.
Q Would banning ice cream reduce drowning deaths? +
A No! Ice cream doesn't cause drownings. Removing the ice cream would have no effect on drownings because there's no causal link.
Q What's the proper way to investigate causation? +
A Controlled experiments (hard here), or statistical controls for confounding variables (temperature, season), or longitudinal studies tracking individuals.
Key Insights
  • Correlation can be perfect (r = 1.0) yet completely spurious
  • Always ask: 'What third variable could cause both?'
  • Establishing causation requires experimental design or careful controls
02

Marketing Spend vs Sales Analysis

A marketing team calculates that advertising spend and monthly sales have r = 0.72 (r² = 0.52). The CEO asks: 'So if we double our ad spend, sales will increase by 72%?'

Sample Data
{
  "r": 0.72,
  "r_squared": 0.52,
  "n": 36
}
Q Is the CEO's interpretation correct? +
A No! r = 0.72 is NOT a percentage increase. It's the strength of linear association. r² = 0.52 means 52% of sales variance is explained by ad spend.
Q What does r² = 0.52 mean in practical terms? +
A 52% of the variation in monthly sales can be 'explained' by variation in ad spend. The other 48% is due to other factors (seasonality, competition, economy, etc.).
Q Can we conclude that advertising CAUSES sales increases? +
A Not from correlation alone. There could be reverse causation (more sales → more ad budget) or confounding (growing economy drives both).
Q What analysis would better answer the CEO's question? +
A Regression analysis with the slope coefficient would show the expected sales change per dollar of ad spend. Even better: an A/B test or natural experiment.
Key Insights
  • r is not a percentage and doesn't indicate magnitude of effect
  • r² (coefficient of determination) is often more interpretable
  • Business decisions need regression coefficients, not just correlation
03

The Suspicious Correlation

A researcher reports r = 0.89 between study hours and exam scores in a class of 25 students. But when you plot the data, you notice something concerning.

Q One student studied 20 hours and scored 95%. All others studied 1-5 hours and scored 40-70%. What's happening? +
A A single outlier is driving the entire correlation! Without that one student, the correlation among the other 24 students might be near zero.
Q Is r = 0.89 a reliable measure of the relationship? +
A No. Pearson's r is highly sensitive to outliers. One extreme point can create or destroy a correlation. Always visualize first!
Q What should the researcher do? +
A Report the correlation with and without the outlier. Use Spearman's ρ (robust to outliers). Most importantly, SHOW THE SCATTER PLOT.
Q What's Anscombe's Quartet and why does it matter? +
A Four datasets with identical correlation (r = 0.816) but completely different patterns: linear, curved, outlier-driven, and vertical cluster. Proves you MUST visualize data.
Key Insights
  • One outlier can inflate correlation from 0 to 0.9
  • ALWAYS plot your data before calculating correlations
  • Anscombe's Quartet: identical r doesn't mean identical relationships
?

Correlation Quiz

Test your understanding • Passing score: 70%

0 of 10 answered
Q1 multiple-choice

What does a Pearson correlation of r = -0.85 indicate?

Explanation: r = -0.85 indicates a strong negative (inverse) relationship. The magnitude |0.85| shows strength (close to 1 = strong), and the negative sign shows direction (as X increases, Y decreases).
Q2 multiple-choice

If r = 0.60, what is r² and what does it mean?

Explanation: r² = (0.60)² = 0.36. This coefficient of determination means 36% of the variance in Y can be explained by its linear relationship with X. The other 64% is unexplained.
Q3 multiple-choice

A study finds that ice cream sales and shark attacks are correlated (r = 0.78). Which conclusion is most appropriate?

Explanation: This is a classic example of confounding. Both ice cream sales and shark attacks increase in summer (more people at beaches, hot weather). The correlation is real but not causal.
Q4 multiple-choice

When should you use Spearman's ρ instead of Pearson's r?

Explanation: Spearman's ρ uses ranks instead of raw values, making it robust to outliers and appropriate for ordinal data. It captures monotonic relationships even if they're curved.
Q5 multiple-choice

A researcher calculates r = 0.02 between two variables. What can they conclude?

Explanation: r ≈ 0 only means no LINEAR relationship. There could be a strong U-shaped, parabolic, or other non-linear relationship that Pearson's r cannot detect. Always visualize!
Q6 multiple-choice

What is 'range restriction' and how does it affect correlation?

Explanation: Range restriction underestimates true correlation. If you only study top students, SAT-GPA correlation appears weaker than in the full population because there's less variation to detect.
Q7 multiple-choice

What does 'correlation does not imply causation' mean?

Explanation: Variables can correlate for many reasons: X causes Y, Y causes X, a third variable causes both, or pure coincidence. Correlation alone cannot distinguish between these possibilities.
Q8 multiple-choice

A dataset has Pearson r = 0.75 and Spearman ρ = 0.98. What does this suggest?

Explanation: When Spearman is much higher than Pearson, it suggests a strong monotonic relationship that isn't perfectly linear (e.g., curved but consistently increasing). Spearman captures the monotonic pattern better.
Q9 multiple-choice

What is the valid range for Pearson's r?

Explanation: Pearson's r ranges from -1 (perfect negative linear relationship) through 0 (no linear relationship) to +1 (perfect positive linear relationship). Values outside this range are impossible.
Q10 multiple-choice

Why is it important to visualize data with a scatter plot before calculating correlation?

Explanation: Scatter plots reveal outliers that can distort r, non-linear relationships that r misses, and unusual patterns. Anscombe's Quartet showed four datasets with identical r but very different patterns.

Quiz Results

0 %

← Non-parametric Methods Next: Simple Regression →