Function model fitting – residuals, R² and linearisation

MathematicsFunctions & GraphsAges 16–17

Loading…

Use with my class ✨ Customize with AI Report a problem

Pick a real-context data set (a cooling drink, drug concentration, world population, yeast growth, a thrown ball, tides, day length, pH, Kepler's third law, printing costs) and fit a linear, quadratic, exponential, exponential-with-asymptote, power, logarithmic, logistic or sinusoidal model by least squares or by dragging the parameters. Residual plots, R² and a comparison table help you choose the best model and test it on new data; the Linearise screen uses semi-log and log–log plots.

Lesson: Modelling with functions: fitting models, residuals, the coefficient of determination R² and linearisation

What it shows

Each model has parameters that the least-squares method chooses so that the sum of squared residuals SSres = Σ(y − ŷ)² is as small as possible. R² = 1 − SSres/SStot measures how much of the variation in y the model explains, and RMSE gives a typical error in the units of y. A model with more parameters never has a lower R², so also judge it by the residual pattern, by what the parameters mean and by how well it predicts new data. Exponential and power models are fitted directly to y; calculators fit them through ln y, which gives slightly different values.

How to use

Choose a Data set and a Model. With Least squares the best parameters appear at once; press Drag parameters and move the sliders to beat the smallest SSres yourself. Watch the Residual plot for a pattern, tick New data to test predictions, and click a row of the table to switch model. On Linearise, change Axes and use Subtract c from y.

Parameters you can change

  • Screen Fit models, Linearise
  • Data set Hot drink cooling, Drug concentration in blood, World population 1950–2000, Yeast growth, Ball thrown upwards, Tide height, Day length through the year, pH of HCl solutions, Orbital periods of the planets, Cost of printing posters, Your own data
  • Model Linear y = ax + b, Quadratic y = a(x − h)² + k, Exponential y = a·bˣ, Exponential with asymptote y = a·bˣ + c, Power y = a·xᵇ, Logarithmic y = a + b·ln x, Logistic y = L/(1 + C·e⁻ᵏˣ), Sinusoidal y = a·sin(b(x − c)) + d
  • Parameters Least squares, Drag parameters
  • Show residual plot
  • Show new data for testing
  • Axes (Linearise screen) y against x, ln y against x (semi-log), ln y against ln x (log–log)
  • Subtract a constant c from y (Linearise screen) 0–50

Questions to explore

  1. Why does a straight line fit the cooling data with a high R² although its residuals show a clear pattern?
  2. Several world population models have R² above 0.99; which predicts 2005–2020 best, and why is a high R² not enough?
  3. Which plot makes the planet data a straight line, and what does its gradient tell you about Kepler's third law?