01 / 21

Regression &
Model Comparison

Master further regression models, learn to analyse residuals, and use goodness-of-fit measures to choose the best model for your data.

IB Math: Applications & Interpretation

What Is Regression?

Regression is the process of fitting a mathematical model to a set of bivariate data. The goal: find the function \( \hat{y} = f(x) \) that best describes the relationship between two variables.

Types of Regression Models

Linear
\( y = ax + b \)
Quadratic
\( y = ax^2 + bx + c \)
Cubic
\( y = ax^3 + bx^2 + cx + d \)
Exponential
\( y = ae^{bx} + c \)  or  \( y = a \cdot b^x \)
Power
\( y = ax^n \)
Sinusoidal
\( y = a\sin(bx+c)+d \)

Understanding Residuals

A residual is the vertical distance between a data point and its predicted value on the regression curve:

x y residual
\( \hat{y} = ax + b \)
data

The \( R^2 \) Coefficient

The coefficient of determination \( R^2 \) measures how much of the variation in \( y \) is explained by the regression model:

\( R^2 = 1 \)
Perfect fit: every point lies exactly on the curve.
\( R^2 = 0 \)
The model explains none of the variation in the data.

\( R^2 \) vs \( r \): Key Distinction

\( r \) (Pearson's) \( R^2 \) (Determination)
Range \( -1 \leq r \leq 1 \) \( 0 \leq R^2 \leq 1 \)
Direction? Yes: sign shows +/ − No: always non-negative
Model type Linear only Any regression model
Relationship For linear models: \( R^2 = r^2 \)

Reading Residual Plots

A residual plot graphs residuals \( e_i \) against the independent variable \( x \). It reveals whether your model is appropriate.

Good: Random Scatter x e Bad: Curved Pattern x e

How to Compare Models

1
Enter data into your GDC and run each regression type (linear, quadratic, exponential, etc.).
2
Record \( R^2 \) for each model. The model with \( R^2 \) closest to 1 explains the most variation.
3
Plot residuals for the top candidates. Check for random scatter (no pattern).
4
Consider context. Does the model make sense for the real-world situation? A cubic might overfit small data sets.
5
Choose the simplest model that has a high \( R^2 \) and random residuals (parsimony principle).

Worked Example: Bacteria Growth

A biologist records the number of bacteria \( N \) (thousands) over time \( t \) (hours):

\( t \) 012345
\( N \) 2.03.14.87.511.618.0

Fitting Two Models

t (hours) N (thousands) 0 1 2 3 4 5 0 5 10 15 20 Linear Exponential
Linear
\( N = 3.06t - 1.37 \)
\( R^2 = 0.957 \)
Exponential
\( N = 2.00e^{0.44t} \)
\( R^2 = 0.999 \)

Residual Analysis

Linear Residuals Curved pattern ✕ Exponential Residuals Random scatter ✓

Example 2: Quadratic vs Power

The distance \( d \) (metres) a ball rolls down a slope is recorded against time \( t \) (seconds):

\( t \) 123456
\( d \) 0.52.14.68.112.718.2
Quadratic
\( d = 0.51t^2 - 0.03t + 0.01 \)
\( R^2 = 0.9998 \)
Power
\( d = 0.50t^{2.01} \)
\( R^2 = 0.9996 \)

Example 3: Sinusoidal Data

Average monthly temperature \( T \) (°C) in a city over 12 months shows a clear periodic pattern. A sinusoidal regression gives:

Month J F M A M J J A S O N D 0 10 20 30

Beware of Overfitting

A model with too many parameters will pass through every data point (\( R^2 = 1 \)) but make terrible predictions. This is called overfitting.

Good Model
Captures the trend in data. Generalises well to new values.
Overfitted Model
Captures noise as well as trend. Fails on new data.

Common Mistakes

✕ Highest \( R^2 \) Wins
A cubic will always beat a linear model on \( R^2 \), but it may overfit. Always check residuals and context.
✕ Using \( r \) for Non-linear
Pearson's \( r \) measures linear correlation only. For curves, use \( R^2 \) from the regression output.
✕ Ignoring Residual Patterns
A high \( R^2 \) with a patterned residual plot means the model is systematically wrong.

Model Comparison Summary

Model Equation Form Best For
Linear \( y = ax + b \) Constant rate of change
Quadratic \( y = ax^2 + bx + c \) One turning point
Exponential \( y = a \cdot e^{bx} \) Growth / decay
Power \( y = ax^n \) Scaling laws
Sinusoidal \( y = a\sin(bx+c)+d \) Periodic / seasonal

Question 1 of 5

A residual is defined as:

Question 2 of 5

A linear regression gives \( R^2 = 0.82 \) and an exponential regression gives \( R^2 = 0.97 \). The residual plot for the exponential model shows random scatter. Which model should you choose?

Question 3 of 5

If a residual plot shows a clear U-shaped curve, what does this indicate?

Question 4 of 5

For a linear regression with \( r = -0.9 \), what is \( R^2 \)?

Question 5 of 5

A data set has 6 points. A polynomial of degree 5 gives \( R^2 = 1 \). Is this model necessarily the best choice?