UNIHIVE

Study Hub UNIPORT STA 160

STA 160 · Descriptive Statistics

Introduction to correlation

Scatter diagrams and correlation coefficients (Pearson's and Spearman's rank), and what a coefficient does and does not tell you.

Our notes

2 min read

Correlation measures the strength and direction of the linear relationship between two variables.

Scatter diagrams

Plot pairs (x, y) as points.

  • Positive correlation: as x increases, y tends to increase (hours studied and marks).
  • Negative correlation: as x increases, y tends to decrease (price and quantity demanded).
  • No correlation: no clear pattern (height and CGPA).
  • Perfect correlation: all points on a straight line.

Pearson's product-moment correlation coefficient (r)

r = [nΣxy − (Σx)(Σy)] / √{[nΣx² − (Σx)²][nΣy² − (Σy)²]}

  • −1 ≤ r ≤ 1. r = +1: perfect positive; r = −1: perfect negative; r = 0: no linear correlation.
  • Rough guide: |r| ≥ 0.7 strong; 0.4–0.7 moderate; below 0.4 weak.

Worked example. x: 1, 2, 3, 4, 5; y: 2, 4, 5, 4, 5 (n = 5).
Σx = 15, Σy = 20, Σxy = 2 + 8 + 15 + 16 + 25 = 66, Σx² = 55, Σy² = 4 + 16 + 25 + 16 + 25 = 86.
Numerator = 5(66) − 15(20) = 330 − 300 = 30.
Denominator = √[(5 × 55 − 225)(5 × 86 − 400)] = √(50 × 30) = √1500 ≈ 38.73.
r = 30/38.73 ≈ 0.77 (strong positive correlation).

Spearman's rank correlation coefficient (rₛ)

Used for ranked (ordinal) data or when the relation is not linear.
rₛ = 1 − 6Σd² / [n(n² − 1)], where d = difference between the two ranks of each item.
Worked example. Five students ranked in Maths (1, 2, 3, 4, 5) and Physics (2, 1, 4, 3, 5).
d = −1, 1, −1, 1, 0; Σd² = 4.
rₛ = 1 − (6 × 4)/(5 × 24) = 1 − 24/120 = 0.8 (strong positive agreement).
Tied ranks: give each tied value the average of the ranks they would occupy (two values tied for 2nd and 3rd both get 2.5).

Coefficient of determination

r² shows the proportion of the variation in y explained by x. With r = 0.77, r² ≈ 0.59: about 59% of the variation is explained.

Correlation is not causation

A strong correlation does not prove that one variable causes the other. Both may be driven by a third factor (ice-cream sales and drownings both rise in hot weather), or it may be coincidence.

Regression (a first look)

The line of best fit (regression line of y on x): y = a + bx, where
b = [nΣxy − ΣxΣy] / [nΣx² − (Σx)²] and a = ȳ − bx̄.
For the example: b = 30/50 = 0.6; ȳ = 4, x̄ = 3; a = 4 − 1.8 = 2.2. So y = 2.2 + 0.6x, which can predict y from x (within the range of the data).

Exams usually ask: draw and interpret scatter diagrams; calculate Pearson's r and Spearman's rₛ (including tied ranks); interpret the values; explain why correlation does not imply causation; find a simple regression line.

Common mistake: concluding that one variable causes the other because r is high.

Written by the UniHive team in our own words. Spotted a mistake? Tell us on WhatsApp.

Read

Watch

Practise

We link to free material and never copy it. Every link was opened by our team before it went up; video data is a rough guide at 360p.

All STA 160 topics

Report

Sign in to report this. It is free.

Is this your work (a lecturer, author or publisher)? Ask us to take it down.