📝 Problem
Find Karl Pearson's correlation coefficient for:
| x | 1 | 2 | 3 | 4 | 5 |
|---|---|---|---|---|---|
| y | 2 | 4 | 5 | 4 | 5 |
Unit IV · Lecture 28 of 40 · B.Sc. Data Science, 1st Year, Semester II
Correlation is a statistical measure that quantifies the strength and direction of the linear relationship between two quantitative variables. The correlation coefficient is a single number that summarises this relationship.
Two dancers (variables) can move in sync (positive correlation), in opposite directions (negative correlation), or independently (no correlation). The correlation coefficient measures how well they synchronise — from −1 (perfect opposite) through 0 (no sync) to +1 (perfect sync).
Sir Karl Pearson was a British mathematician and biometrician who founded the field of mathematical statistics. He developed the product-moment correlation coefficient (now called Pearson's r) in the 1890s, building on work by Francis Galton. Pearson also founded the world's first university statistics department at University College London.
As x increases, y tends to increase. Height & weight.
As x increases, y tends to decrease. Price & demand.
No linear relationship. Shoe size & IQ.
r = Σ(xᵢ−x̄)(yᵢ−ȳ) / √[Σ(xᵢ−x̄)² · Σ(yᵢ−ȳ)²]
Form 2 (Raw data — no deviations):
r = [nΣxy − Σx·Σy] / √{[nΣx² − (Σx)²] · [nΣy² − (Σy)²]}
Form 3 (Using covariance and standard deviations):
r = Cov(x,y) / (Sₓ · Sᵧ) where Cov(x,y) = Σ(xᵢ−x̄)(yᵢ−ȳ)/n
Find Karl Pearson's correlation coefficient for:
| x | 1 | 2 | 3 | 4 | 5 |
|---|---|---|---|---|---|
| y | 2 | 4 | 5 | 4 | 5 |
| x | y | xy | x² | y² |
|---|---|---|---|---|
| 1 | 2 | 2 | 1 | 4 |
| 2 | 4 | 8 | 4 | 16 |
| 3 | 5 | 15 | 9 | 25 |
| 4 | 4 | 16 | 16 | 16 |
| 5 | 5 | 25 | 25 | 25 |
| 15 | 20 | 66 | 55 | 86 |
n = 5, Σx = 15, Σy = 20, Σxy = 66, Σx² = 55, Σy² = 86
Numerator: nΣxy − Σx·Σy = 5(66) − (15)(20) = 330 − 300 = 30
Denominator:
nΣx² − (Σx)² = 5(55) − 225 = 275 − 225 = 50
nΣy² − (Σy)² = 5(86) − 400 = 430 − 400 = 30
√(50 × 30) = √1500 = 38.73
r = 30 / 38.73 = 0.7746
Moderate to strong positive correlation. As x increases, y tends to increase. About 60% of the variation in y is explained by the linear relationship with x (r² = 0.60).
Find the correlation between study hours and exam scores:
| Hours (x) | 2 | 3 | 5 | 6 | 8 |
|---|---|---|---|---|---|
| Score (y) | 50 | 55 | 65 | 70 | 80 |
| x | y | xy | x² | y² |
|---|---|---|---|---|
| 2 | 50 | 100 | 4 | 2500 |
| 3 | 55 | 165 | 9 | 3025 |
| 5 | 65 | 325 | 25 | 4225 |
| 6 | 70 | 420 | 36 | 4900 |
| 8 | 80 | 640 | 64 | 6400 |
| 24 | 320 | 1650 | 138 | 21050 |
n = 5
Numerator: 5(1650) − (24)(320) = 8250 − 7680 = 570
Denominator: √{[5(138) − 576] · [5(21050) − 102400]}
= √{[690 − 576] · [105250 − 102400]}
= √{114 × 2850} = √324900 = 570.0
r = 570 / 570 = 1.000
Perfect positive linear correlation. All points lie exactly on a straight line. Study hours perfectly predict exam score in this dataset.
The coefficient of determination, r², measures the proportion of variance in y that is explained by the linear relationship with x. It is the square of the correlation coefficient.
r² = (explained variation) / (total variation)
| r | r² | Interpretation |
|---|---|---|
| +1.0 or −1.0 | 1.00 (100%) | Perfect linear fit — all variance explained |
| +0.9 or −0.9 | 0.81 (81%) | Very strong — most variance explained |
| +0.7 or −0.7 | 0.49 (49%) | Moderate — about half the variance explained |
| +0.5 or −0.5 | 0.25 (25%) | Moderate — quarter of variance explained |
| +0.3 or −0.3 | 0.09 (9%) | Weak — very little variance explained |
| 0 | 0 (0%) | No linear relationship |
| |r| Range | Strength | Typical Description |
|---|---|---|
| 0.00 – 0.19 | Very weak | Negligible or no linear relationship |
| 0.20 – 0.39 | Weak | Some tendency, but unreliable for prediction |
| 0.40 – 0.59 | Moderate | Noticeable relationship, useful for rough prediction |
| 0.60 – 0.79 | Strong | Good linear relationship, useful for prediction |
| 0.80 – 1.00 | Very strong | Excellent linear relationship, reliable prediction |
A classical test for significance: PE(r) = 0.6745(1−r²)/√n. If |r| > 6 × PE(r), the correlation is considered significant. If |r| < PE(r), it is not significant. Modern practice uses hypothesis testing (t-test) instead, but this formula appears in many textbooks.
Q1: The range of Pearson's r is:
Q2: If r = 0.8, then r² = 0.64 means:
Q3: Pearson's r measures:
Q4: r(x,y) = 0.7. What is r(y,x)?
Q5: If all points lie exactly on a line sloping downward, r equals:
Q6: r = 0 for a U-shaped scatter. This means:
1. Compute r for: x = 10, 20, 30, 40, 50 and y = 15, 25, 30, 40, 55.
2. Compute r for: x = 2, 4, 6, 8, 10 and y = 10, 8, 6, 4, 2. Interpret the result.
3. If r = 0.6 between advertising and sales, interpret r². What percentage of sales variation is NOT explained by advertising?
4. Explain why r is called "unit-free." Give an example.
5. Can r be misleading? Construct a dataset of 5 points where r ≈ 0 but the points clearly follow a U-shaped pattern.
6. BONUS: Show that if y = a + bx (perfect linear relationship with b > 0), then r = +1.
Lecture 29: Partial and Multiple Correlation — extending correlation to three or more variables.