Math for Data Science · Lesson 4

Correlation coefficient R

How can we describe the direction and strength of a linear relationship between two variables?

The big idea

One number, two clues

Pearson’s correlation coefficient, often written as r or R, describes the direction and strength of a linear relationship between two numerical variables. Its value lies between −1 and +1, inclusive.

Positive

As one variable increases, the other tends to increase.

Negative

As one variable increases, the other tends to decrease.

Near zero

Little or no linear association; a curved pattern may still exist.

−1
Perfect negative
0
No linear correlation
+1
Perfect positive

The closer R is to −1 or +1, the stronger the linear relationship. The sign shows direction; the distance from zero shows strength. Descriptions such as “strong” depend on context.

Worked example

Age and blood pressure

Each row represents one paired observation. Suppose the following values are recorded for eight people:

Age (years)Blood pressure (mmHg)
25112
30118
35121
40128
45132
50138
55142
60150

For these data, R ≈ 0.997. The positive sign tells us the measurements tend to rise together; the value close to +1 indicates a very strong positive linear association in this small example.

This is an illustrative data set, not evidence that age alone causes blood pressure to rise. Other factors and the way the sample was selected matter.

The mathematics

How R is calculated

Subtract the mean from each observation, multiply paired deviations, and compare their total with the size of the deviations in both variables.

R=∑(xi−x¯)(yi−y¯)∑(xi−x¯)2∑(yi−y¯)2

Here, x̄ and ȳ are the sample means. R is undefined if either variable has no variation, because the denominator is zero.

Think carefully

Three points to remember

Look at the plot

A scatter plot can reveal curves, clusters or outliers that one number hides.

Watch for outliers

An unusual point can change R substantially. Investigate it before drawing conclusions.

Association ≠ cause

Correlation alone cannot establish that one variable causes the other.

Keep learning

Continue your journey

Review scatter plots or practise correlation and regression calculations.

Formula Library
Latest
Latest Content Auto
Home