Measuring Associations Between Two Continuous Variables#

Stage 2 · 🔗 Associations & Correlation · Lesson 11 of 56 · beginner

◀ Previous · Measuring Associations in Data · Next · Correlation Coefficients in Python (Pearson, Spearman, Kendall) ▶ · ↑ Section

Important

✨ AI-generated content. This page was written with the assistance of an AI language model and is provided as a learning aid. Despite careful review, it may still contain mistakes, omissions, or out-of-date information. Whether you are new to the topic, a team lead, or a senior practitioner, treat it as a starting point rather than an authoritative reference: read it critically and independently verify anything you act on (code, commands, figures, and factual claims) against official documentation and primary sources before relying on it.

Covariance: direction#

The starting point for two continuous variables is covariance, which measures whether they vary in the same direction:

\[\operatorname{cov}(X, Y) = \frac{1}{n-1}\sum_{i=1}^{n} (x_i - \bar{x})(y_i - \bar{y}).\]

When above-average \(x\) tends to pair with above-average \(y\), the products are positive and covariance is positive; when high \(x\) pairs with low \(y\), it is negative; near zero means no linear tendency.

The problem with covariance#

Covariance has a flaw as a strength measure: its size depends on the variables’ units. Covariance of fare and distance changes if you switch miles to kilometres, so its magnitude is not comparable across variable pairs — it ranges without bound. You can read its sign, but not judge “how strong” from its value.

Pearson correlation#

The fix is to standardise covariance by the two standard deviations, giving the Pearson correlation coefficient:

\[r = \frac{\operatorname{cov}(X, Y)}{\sigma_X \, \sigma_Y} = \frac{\sum_{i=1}^{n} (x_i - \bar{x})(y_i - \bar{y})} {\sqrt{\sum (x_i - \bar{x})^2}\,\sqrt{\sum (y_i - \bar{y})^2}}.\]

Dividing out the units confines \(r\) to the range \([-1, 1]\), making it comparable everywhere.

Reading r#

On that scale, \(r = +1\) is a perfect positive linear relationship, \(r = -1\) a perfect negative one, and \(r = 0\) no linear relationship. The crucial caveat: Pearson measures linear association only. A strong curved relationship can still give \(r \approx 0\), and \(r\) is sensitive to outliers — reasons the next lesson reaches for rank-based alternatives.

See also

Source article Adapted (context, re-expressed) in our own words from: https://insightful-data-lab.com/2026/01/14/measuring-associations-between-two-continuous-variables/ (insightful-data-lab.com).

Tags: purpose: reference topic: data analysis topic: data preparation level: beginner