01 / 21

Correlation &
Regression

Discover how to measure the strength of relationships between variables and find the line of best fit using least-squares regression.

IB Mathematics AA

What Is Correlation?

Correlation describes the strength and direction of a linear relationship between two quantitative variables. When one variable increases and the other tends to increase too, we say there is a positive correlation. When one increases while the other decreases, the correlation is negative.

Visualising Data with Scatter Diagrams

Independent variable \(x\)
Dependent variable \(y\)
best fit

A scatter diagram plots paired data as points on the \(xy\)-plane. The pattern of points reveals the type and strength of correlation. A line of best fit summarises the overall trend.

Types of Correlation

Strong Positive
Points cluster tightly around an upward-sloping line. \(r\) close to \(+1\).
Strong Negative
Points cluster tightly around a downward-sloping line. \(r\) close to \(-1\).
No Correlation
Points show no linear pattern. \(r\) close to \(0\). No line fits the data well.

The Correlation Coefficient \(r\)

$$r = \frac{S_{xy}}{\sqrt{S_{xx} \cdot S_{yy}}}$$

\(S_{xy}\)
\(\displaystyle \sum(x_i - \bar{x})(y_i - \bar{y})\)
\(S_{xx}\)
\(\displaystyle \sum(x_i - \bar{x})^2\)
\(S_{yy}\)
\(\displaystyle \sum(y_i - \bar{y})^2\)

Interpreting \(r\) Values

\(-1\)
\(-0.5\)
\(0\)
\(0.5\)
\(1\)
Strong \(-\)
Strong \(+\)
Weak / None
1
\(|r|\) close to 1: strong linear relationship.
2
\(|r|\) close to 0: weak or no linear relationship.
3
Sign of \(r\): positive means both variables increase together; negative means one increases as the other decreases.

The Regression Line \(y = ax + b\)

The least-squares regression line of \(y\) on \(x\) minimises the sum of squared vertical distances from each point to the line:

$$a = \frac{S_{xy}}{S_{xx}}, \qquad b = \bar{y} - a\bar{x}$$

Correlation vs Regression

Correlation Regression
Purpose Measures strength of linear relationship Finds the equation of the best-fit line
Output A number: \(r \in [-1, 1]\) An equation: \(y = ax + b\)
Symmetric? Yes: \(r_{xy} = r_{yx}\) No: \(y\) on \(x\) differs from \(x\) on \(y\)
Used for Describing association Making predictions

How to Find \(r\) and \(y = ax + b\)

1
Plot the data on a scatter diagram. Identify the independent (\(x\)) and dependent (\(y\)) variable.
2
Calculate the means \(\bar{x}\) and \(\bar{y}\), and the sums \(S_{xy}\), \(S_{xx}\), \(S_{yy}\).
3
Compute \(r\) using \(r = S_{xy} / \sqrt{S_{xx} \cdot S_{yy}}\). Interpret its sign and magnitude.
4
Find the gradient: \(a = S_{xy} / S_{xx}\) and the \(y\)-intercept: \(b = \bar{y} - a\bar{x}\).
5
Write the equation \(y = ax + b\) and draw it through \((\bar{x}, \bar{y})\).

Example 1: Computing \(r\)

Five students' study hours (\(x\)) and test scores (\(y\)) are recorded:

\(x\) 24578
\(y\) 5058637277

Example 2: Finding the Regression Line

Using the same data from Example 1, find the equation of the regression line \(y\) on \(x\).

Example 3: Making a Prediction

A student studies for 6 hours. Using the regression line \(y = 4.52x + 40.5\), estimate their test score.

Hours studied (\(x\))
Score (\(y\))
\(2\)
\(4\)
\(6\)
\(8\)
\(50\)
\(60\)
\(70\)
\(80\)
\(67.6\)

Interpolation vs Extrapolation

Interpolation
Predicting within the range of the data. Generally reliable if \(r\) is strong.
Extrapolation
Predicting outside the range of the data. Often unreliable: the trend may not continue.

Coefficient of Determination \(r^2\)

\(r^2\) tells us the proportion of variation in \(y\) that is explained by the linear relationship with \(x\).

1
\(r^2 = 1\): the line explains all variation (perfect fit).
2
\(r^2 = 0\): the line explains none of the variation.
3
\(r^2\) is always between 0 and 1, regardless of the sign of \(r\).

Common Mistakes

✕ Confusing Correlation with Causation
A high \(|r|\) does not prove that \(x\) causes \(y\). Always consider lurking variables and study design.
✕ Extrapolating Beyond the Data
Using the regression line far outside the observed \(x\)-range produces unreliable predictions.
✕ Swapping the Regression Lines
The line of \(y\) on \(x\) is different from \(x\) on \(y\). Always use the correct one for the variable you are predicting.

Key Formulas Summary

Quantity Formula Interpretation
\(r\) \(\dfrac{S_{xy}}{\sqrt{S_{xx} \cdot S_{yy}}}\) Strength and direction
\(r^2\) \(\left(\dfrac{S_{xy}}{\sqrt{S_{xx} \cdot S_{yy}}}\right)^2\) % of variation explained
Gradient \(a\) \(\dfrac{S_{xy}}{S_{xx}}\) Change in \(y\) per unit \(x\)
Intercept \(b\) \(\bar{y} - a\bar{x}\) Value of \(y\) when \(x = 0\)
Mean point \((\bar{x}, \bar{y})\) Line always passes through it

Question 1 of 5

A data set has \(r = -0.92\). Which statement is most accurate?

Question 2 of 5

The regression line of \(y\) on \(x\) is \(y = 3x + 5\) and \(\bar{x} = 4\). What is \(\bar{y}\)?

Question 3 of 5

If \(r = 0.8\), what percentage of the variation in \(y\) is not explained by \(x\)?

Question 4 of 5

Data were collected for \(x\) values between \(10\) and \(40\). Using the regression line to predict \(y\) when \(x = 25\) is an example of:

Question 5 of 5

Given \(S_{xy} = 150\), \(S_{xx} = 50\), \(\bar{x} = 6\), and \(\bar{y} = 25\), what is the equation of the regression line \(y\) on \(x\)?