James Ashton MathsFREE MATHEMATICS. OPEN TO EVERYONE.
HomeIB DiplomaA levelAbout
IB Diploma › Maths AI HL › Statistics & probability › Non-linear regression

Non-linear regression

Not every relationship is a straight line. Your GDC can fit quadratic, cubic, exponential, power and sine models by least squares. The skill the exam rewards is judging the fit: the sum of square residuals and R2 measure it, but context decides which model makes sense.

AHL 4.13HL onlyPaper 1Paper 2Paper 3GDC allowed≈ 45 min to work through
Before you start: linear regression and r (Correlation & regression) and the model families (Linear, quadratic & cubic models, Exponential & sinusoidal models, Variation).

1What you need to know

Tick these off as you go. By the end of the page you should be able to do all of them without notes.

  • Use the GDC to find least squares regression curves: quadratic, cubic, exponential, power and sineAHL 4.13
  • Calculate and interpret the sum of square residuals, SSresAHL 4.13
  • Find and interpret the coefficient of determination R2AHL 4.13
  • Know that R2=r2 for a linear modelAHL 4.13
  • Explain why R2 alone is not a good way to choose between modelsAHL 4.13
  • Use a model to predict, and comment on the reliability of the predictionAHL 4.13

2Notes & worked examples

Each idea is followed by a worked example. Try the question yourself first, then reveal the solution one step at a time.

The big idea

A residual is the vertical gap between a data point and the model: observed minus predicted. The least squares model is the one that makes the total of the squared residuals as small as possible. Your GDC finds it for you; your job is to choose a sensible type of model and judge how well it fits.

2.1 The sum of square residuals

Sum of square residuals Not in booklet: learn it
SSres=∑i=1n(yi−f(xi))2

The smaller SSres, the closer the model is to the data. It has the units of y squared, so you can only compare it between models fitted to the same data.

Worked example 1Paper 1
The model y=2x+1 is fitted to the points (1,3.5), (2,4.6), (3,7.4) and (4,8.8). Find SSres.
Predicted: 3, 5, 7, 9
Residuals: 0.5, −0.4, 0.4, −0.2
SSres=0.25+0.16+0.16+0.04=0.61

2.2 The coefficient of determination

R2 is the proportion of the variability in y that is explained by the model. It lies between 0 and 1: R2=0.95 means 95% of the variation in y is accounted for by the model. For a linear model, R2=r2, the square of Pearson’s correlation coefficient. (It can be shown that R2=1−SSresSStot, so R2=1 exactly when every point lies on the curve; you will not be examined on this.)

A bacteria culture is counted every hour.

Time, t hours0123456
Bacteria, N120165230310440590820
Worked example 2Paper 2
Find an exponential model N=abt, state R2, and use the model to predict the count after 8 hours. Comment on the prediction.
ExpReg on the GDC: N=120.2×1.377t
a = 120.171…, b = 1.37725…
R2=0.99978: almost all the variation in N is explained by the model.
N(8)=120.171×1.377258≈1560 bacteria
This is extrapolation (8 is outside 0 to 6), so it is less reliable: growth may slow as food runs out.

2.3 Choosing between models

A model with more parameters (a cubic rather than a quadratic) always fits at least as well, so R2 can only go up. That does not make it a better model. Use R2 together with: the context (should the model pass through the origin? grow without limit? level off?), the shape of the residuals, and how the model behaves outside the data.

x123456
y2.35.611.216.023.429.6
Worked example 3Paper 2
For the data above, compare linear, quadratic, cubic and power models. Which would you choose if y must be 0 when x=0?
R2: linear 0.988, quadratic 0.998, cubic 0.999, power 0.998
Power: y=2.22x1.44, which passes through the origin.
The quadratic gives y=−1.17 at x=0, and the cubic 0.53.
Choose the power model: almost the same fit, fewer parameters, and it matches the context.
Worked example 4 (faded)Paper 1
For a linear model, r=−0.92. Find R2.
R2=r2=(−0.92)2= 0.846  ← you work this out

Sine regression fits y=asin(b(x−c))+d to periodic data such as hours of daylight or tides. The GDC needs enough points across at least one full cycle; read the period as 2πb (in radians) and check it makes sense, for example close to 365 days for daylight.

On your TI-Nspire Calculator tricks →

On the TI-Nspire, enter the data in two lists in a Lists & Spreadsheet page, then menu → Statistics → Stat Calculations and choose Quadratic, Cubic, Exponential, Power or Sinusoidal Regression. The output gives the parameters and R2 (or r2). Store the equation in f1 to graph it over a scatter plot. Note that the exponential and power r2 are worked out from the logged data, which is the value the IB expects you to quote.

3Explore it

The six points are the data from WE3. Choose a model type: the curve is the least squares fit and the red lines are the residuals. The readout gives SSres and R² worked out on the original data (the GDC’s R² for exponential and power models uses the logged data, so it can differ slightly).

4Common mistakes & exam tips

Common mistakes

  • Choosing the model with the highest R2 without thinking about the context.
  • Comparing SSres for models fitted to different data sets.
  • Rounding the parameters early, then using the rounded model for predictions.
  • Calling a prediction outside the data range reliable because R2 is high.
  • Confusing R2 with r: for a linear model with negative correlation, r is negative but R2 is positive.

Exam tips

  • Write the model with the parameters to at least 3 significant figures, and use the stored values for predictions.
  • "Interpret R2" means a sentence: "about 99% of the variation in N is explained by the model".
  • Always mention extrapolation when predicting outside the data.
  • Sketch or look at the data first: the shape usually suggests the model family.

5Practice

Fluency questions build the basics. Problem-solving questions make you think about which method to use.

FluencyP1
Find SSres for the model y=3x and the points (1,2), (2,7), (3,9).
Residuals −1,1,0; SSres=2
FluencyP2
A linear model has R2=0.64 and a negative gradient. Find r.
r=−0.8
FluencyP3
Two models for the same data have SSres=4.2 and SSres=1.7. Which fits better?
The second (smaller SSres).
FluencyP4
Explain why a cubic model always has R2 at least as large as a quadratic model for the same data.
A quadratic is a cubic with the x3 coefficient 0, so the best cubic is at least as good.
Problem solvingP5
Using the bacteria data, explain why an exponential model is more suitable than a quadratic for the long term.
Bacteria grow by a percentage each hour (constant ratio); a quadratic does not, and turns round for negative t.
Problem solvingP6
A sine model for daylight hours gives b=0.0172. Find the period and comment.
2π0.0172=365 days: one year, as expected.

6Exam-style questions

Original questions in the style of the IB Maths AI HL exam, with full markschemes. Your GDC is allowed throughout: use it, but write down what you entered and what it gave you. Give yourself about 1 minute per mark.

Question 1Paper 1[6 marks]

The braking distance of a car, d metres, was measured at different speeds, v km h⁻¹.

Speed, v km h⁻¹203040506070
Distance, d m6.111.820.530.242.656.0

  • (a)Find a model of the form d=avb.[2]
  • (b)Write down the value of R2 for this model and interpret it.[2]
  • (c)Use the model to estimate the braking distance at 90 km h⁻¹, and comment on the reliability of your estimate.[2]
(a)
a=0.0284A1
b=1.78A1
(b)
R2=0.999A1
99.9% of the variation in braking distance is explained by the modelR1
(c)
86.9 mA1
not reliable: 90 is outside the data range (extrapolation)R1
Question 2Paper 2[8 marks]

A cup of tea cools in a room. The difference between the tea’s temperature and room temperature, D °C, is recorded every 5 minutes.

Time, t min051015202530
Temperature above room, D °C62.047.536.128.421.016.312.5

  • (a)Find an exponential model D=abt.[2]
  • (b)Write down the value of R2.[1]
  • (c)A quadratic model is also fitted. Find this model and its sum of square residuals.[2]
  • (d)The exponential model has SSres=0.486. Use your models to predict D after 60 minutes, and hence explain which model is more suitable.[3]
(a)
a=62.1A1
b=0.948A1
(b)
R2=0.9997A1
(c)
D=0.0417t2−2.87t+61.4A1
SSres=2.26A1
(d)
exponential: 2.51 °CA1
quadratic: 39.6 °CA1
the exponential model is better: it has the smaller SSres, and the quadratic wrongly predicts the tea warming up againR1
Question 3Paper 1[5 marks]

For a set of data on hours of revision, x, and test errors, y, Pearson’s correlation coefficient is r=−0.92.

  • (a)Find R2 for the linear model and interpret it.[2]
  • (b)A quadratic model has R2=0.87. State, with a reason, which model fits the data better.[1]
  • (c)Give two reasons why R2 alone should not be used to choose between the models.[2]
(a)
0.846A1
84.6% of the variation in errors is explained by the linear modelR1
(b)
quadratic, since 0.87>0.846R1
(c)
a model with more parameters always has a higher (or equal) R2R1
the context matters, for example a quadratic would predict errors increasing again for large xR1

7Check yourself

Six quick questions, marked instantly. Aim for 6/6 before moving on. Fractions like 3/2 are accepted.

8Past-paper practice

Once you are scoring well above, try these real IB Maths AI HL questions on this topic. Your school or teacher will have the papers.

PaperQuestionFocusDifficulty
Nov 2024 · Paper 1Q12Heights of a bouncing ball: fitting a model with technology★★☆
May 2025 · TZ2 · Paper 1Q14Comparing two regression models using R2★★☆
May 2023 · TZ1 · Paper 2Q1Earth’s temperatures: choosing and using a regression model★★☆
May 2025 · TZ1 · Paper 2Q3Population of Los Angeles: comparing models★★★
Spotted a mistake on this page?Tell me and I'll fix it. The button opens an email with this page already named, or write to jamesashtonmaths@gmail.com.
Report a mistake