GUIDE 08

Correlation vs Regression: Pearson r, Spearman ρ and Interpreting the Slope

Pearson vs Spearman, r², reading a regression slope, correlation vs causation and outliers, with a worked example.

Correlation and regression are the first tools to reach for when you want to know whether two variables move together. Their calculations overlap heavily, but they ask different questions. Correlation asks "how strongly do the two variables move together?" Regression asks "when x changes by one unit, how much does y change on average?"

Pearson correlation coefficient r

Pearson's r expresses the strength and direction of a linear relationship between two continuous variables, on a scale from −1 to 1.

  • r = Sxy / √(Sxx × Syy)
  • Sxy = Σ(x−x̄)(y−ȳ), Sxx = Σ(x−x̄)², Syy = Σ(y−ȳ)²

An r near 1 means a strong positive linear relationship, near −1 a strong negative one, and near 0 a weak linear relationship. Standards of strength vary by field, but absolute values of 0.1, 0.3 and 0.5 are often used as weak, moderate and strong.

An r near 0 does not mean no relationship. A clear curve such as y = x² can have r close to 0. That is why you should always look at a scatter plot before computing a correlation.

Spearman rank correlation ρ

Spearman's ρ is Pearson's r computed on ranks instead of raw values. Without ties it equals this simple formula:

  • ρ = 1 − 6Σd² / (n(n²−1)) (d is the rank difference within each pair)

Spearman's ρ captures monotonic relationships, ones that consistently rise or fall even if not in a straight line, and is less affected by outliers. It also works for ordinal data such as satisfaction rankings.

Example: study hours and scores

Study hours (x) and scores (y) for six students:

Studentxyx−x̄y−ȳ(x−x̄)(y−ȳ)
1152−2.5−9.66724.167
2255−1.5−6.66710.000
3361−0.5−0.6670.333
44600.5−1.667−0.833
55681.56.3339.500
66742.512.33330.833

Step 1: Means

x̄ = 21 / 6 = 3.5, ȳ = 370 / 6 ≈ 61.667

Step 2: Sums of squares and cross-products

  • Sxy = 24.167 + 10.000 + 0.333 − 0.833 + 9.500 + 30.833 = 74
  • Sxx = 6.25 + 2.25 + 0.25 + 0.25 + 2.25 + 6.25 = 17.5
  • Syy ≈ 333.333

Step 3: Pearson r

r = 74 / √(17.5 × 333.333) = 74 / √5833.33 ≈ 74 / 76.376 ≈ 0.9689

A very strong positive linear relationship. The test of this r (null hypothesis ρ = 0, 4 degrees of freedom) gives a two-sided p-value of about 0.0014.

Step 4: Spearman ρ

The x ranks are simply 1 to 6, and the y ranks are 1, 2, 4, 3, 5, 6 (60 is less than 61, so students 3 and 4 swap ranks). The rank differences d are 0, 0, −1, 1, 0, 0, so Σd² = 2.

ρ = 1 − 6 × 2 / (6 × (36 − 1)) = 1 − 12 / 210 ≈ 0.9429

Step 5: Regression line

  • Slope: b = Sxy / Sxx = 74 / 17.5 ≈ 4.2286
  • Intercept: a = ȳ − b × x̄ = 61.667 − 4.2286 × 3.5 ≈ 46.867
  • Equation: ŷ ≈ 46.867 + 4.2286x

Reading the slope and r²

  • Slope 4.2286: a student who studied one more hour is predicted to score about 4.23 points higher on average. The slope has units (points per hour), so changing the units of x or y changes it. r, by contrast, has no units.
  • Intercept 46.867: the predicted value at x = 0, meaning no study at all. The data contain no x = 0, so this is an extrapolation beyond the observed range and should be read with care.
  • Coefficient of determination r² ≈ 0.9387: about 93.9% of the total variation in scores is explained by the linear relationship with study hours. In simple regression, r² equals the square of Pearson's r.

The slope and r always share the same sign, and b = r × (s_y / s_x). With the same r, a larger spread in y means a steeper slope.

The effect of an outlier

Add one more student to the data: 7 hours of study but a score of 30 (say, the student was ill on test day).

MeasureOriginal 6With the outlier, 7
Pearson rabout 0.9689about −0.1149
Spearman ρabout 0.9429about 0.2143

One point flipped even the sign of Pearson's r. Because Pearson's r uses means and squared deviations, a single point extreme in both x and y can dominate it. Spearman's ρ was affected too, but by less, since it uses ranks. This suggests the following order:

  1. Check the scatter plot for outliers and curvature first.
  2. Find out whether the outlier is a data entry error or a real value.
  3. If it is real, report results with and without it, or present Spearman's ρ alongside.

Correlation is not causation

Even a strong correlation does not show that x causes y. Common reasons:

  • A third variable (confounder): ice cream sales and swimming accidents rise together, but both are driven by temperature.
  • Reverse causation: correlation alone cannot tell whether active people are healthy or healthy people are more active.
  • Chance: examine enough pairs of variables and strong correlations will appear between unrelated ones.
  • Selection bias: if only people meeting certain conditions enter the sample, correlations can appear or disappear.

A causal claim needs a randomized experiment or a study design that controls confounders systematically. The regression slope is likewise safest read not as "changing x changes y" but as "among subjects whose x differs by one unit, y differs this much on average".

Which one to use

SituationRecommended
Two continuous variables, straight-line relationship, no outliersPearson r
Monotonic but curved, outliers present, or ordinal dataSpearman ρ
You want to predict y from x or estimate the rate of changesimple linear regression (slope, intercept, r²)

Paste x, y pairs into this site's correlation and regression calculator to get Pearson's r, Spearman's ρ, the regression equation and r² at once.

Key takeaways

  • Pearson's r measures the strength of a linear relationship; Spearman's ρ measures a rank-based monotonic relationship.
  • In the six-pair example, r ≈ 0.9689, ρ ≈ 0.9429, the regression line is ŷ ≈ 46.867 + 4.2286x and r² ≈ 0.9387.
  • The slope is the average change in y per unit of x (it has units); r² is the share of variation in y explained by the linear relationship.
  • A single outlier can move Pearson's r from 0.9689 to −0.1149, so look at the scatter plot first.
  • Neither correlation nor a regression slope proves causation.

→ Calculate it now: Correlation

Updated 2026-09-23