02 · Learning path

Correlation

Normalized covariance: a number between -1 and 1 that measures the strength of a linear relationship.

  • statistics
  • linear relationship
  • Pearson

Pearson correlation is probably the most widely used measure of the relationship between two variables. Unlike covariance, it is normalized and always lies between -1 and 1.

Definition

The correlation divides the covariance by the product of the standard deviations:

where is the covariance and , are the standard deviations of and . With sample data, the estimator is written .

Interpretation

  • 1: perfect positive linear relationship.
  • 0: no linear relationship.
  • -1: perfect negative linear relationship.

Play with a sample

Change the target correlation and the sample size. You will see that the observed coefficient fluctuates because of sampling noise, even though the underlying relationship is always the same.

Correlation lab

Pearson in real time

r = 0.683 · moderate
X (rescaled)Y (rescaled)

Settings

With small n, r fluctuates a lot around ρ.

Reading

Positive relationship

r = 0.683; r² = 0.467, i.e. the line explains 46.7% of the variance of Y.

Observed r

0.683

95% CI (Fisher)

[0.46, 0.83]

Slope

0.773

  • r ≥ 0
  • r < 0
  • Least-squares line

What to look for

  • Push ρ to ±0.95 and the cloud tightens around the line.
  • Lower n: the CI widens and r drifts away from ρ.
  • r only measures linear association; it does not imply causation.

Why it is better than covariance

Because it lives in a fixed range, it lets you compare the relationship between “height and weight” with that between “temperature and electricity consumption” without worrying about units.

Caution