Non-linear regression and R²
In a minute
Real data often follow a curve, not a line. Your GDC finds the best curve of the type you choose, and you judge the fit with the and . A high never settles the choice alone: the context matters too.
You'll be able to
- Fit quadratic, cubic, exponential, power and sine models with your GDC, and write the model in context.
- Find and the sum of square residuals for a model, and use to compare fits.
- Find with your GDC and interpret it as the proportion of the variation in that the model accounts for.
- Use for a linear model, and see why when .
- Choose between models using context, the shape of the data and , not alone.
Before you start3 quick questions on what this builds on
Revise first: 1.3 Geometric sequences and series, 2.2 Function concepts, domain and range, 2.5 Modelling with functions, 2.6 Fitting and testing models, 2.10 Logarithmic scales and linearizing data and 4.4 Correlation and regression (y on x)
Fitting curves with your GDC
In 4.4 you fitted a straight line. Many real relationships curve instead: revenue that peaks, a drug that wears off, daylight that rises and falls through the year.
You choose the type of model. Your GDC then finds its by : of all curves of that type, it picks the one that passes closest to the points, measured vertically. For exponential and power models, the GDC does this for instead of .
The model types in exam questions, with the pattern that suggests each:
1. Linear : a steady rate of change. 2. Quadratic : one peak or one trough. 3. Cubic : up to two turning points.
4. Exponential : the same percentage change for each step in , with , growth if and decay if . 5. Power : varies with a power of , as mass varies with length. 6. Sine : a repeating cycle, such as tides.
Try it first, then reveal one step at a time.
- The revenue rises and then falls: one peak, so a quadratic suits the shape.
- Enter in the first list and in the second, and run quadratic regression. Write down that you did: this earns the method mark.
- The GDC gives , , . So , with each parameter to 3 s.f.
- The peak is at the vertex: . Use the stored values, not the rounded ones.
- Interpret: the model suggests charging about $4.42, which gives about $742 a week. This price lies inside the range tested, so the estimate is an interpolation.
Try it first, then reveal one step at a time.
- Each hour falls by a similar fraction: and . That suggests exponential decay.
- Enter and in two lists and run exponential regression ().
- The GDC gives and , so .
- Interpret : each hour the concentration is multiplied by , so it falls by about per hour. The model's values at form a with common ratio .
- Interpret : mg per litre is the model's value at . Caffeine takes time to be absorbed, so the model only describes the fall after the first hour.
Some models add a known constant, such as for a drink cooling in a room at . The GDC's exponential regression has no added constant. So subtract from every first, then run the regression on against .
Residuals and the sum of square residuals
How close is a model to the data? Look at the vertical gap between each point and the curve. In 4.4 the made the squares of these gaps add up to as little as possible.
Positive and negative residuals partly cancel, so their plain sum tells you little. Squaring makes every gap count, and big gaps count most.
Try it first, then reveal one step at a time.
- Predicted heights: , , , .
- Residuals, observed minus predicted: , , , .
- Interpret: every prediction is within cm of the measured height, so the model fits these four weeks closely.
Try it first, then reveal one step at a time.
- Predicted distances: , , and .
- .
- Collect terms. : . : . Constant: .
- So , a parabola that opens upwards.
- Its minimum is at the vertex: You could also graph it and find the minimum on your GDC.
- So the least squares model is . Any other gives a larger : that is what least squares means.
The coefficient of determination
The -values in a data set vary. Part of that variation follows the model: as changes, the model's changes too. The rest is scatter that the model misses.
Close to : the points lie close to the curve. Close to : the model accounts for little of the variation. Interpret it with the context's variable names.
Try it first, then reveal one step at a time.
- Enter the lists and run linear regression. The GDC gives and
- For a linear model , so to 3 s.f.
- Interpret: about of the variation in rent between these flats is accounted for by the linear model in distance.
- The other comes from things the model leaves out, such as floor area or condition.
Try it first, then reveal one step at a time.
- rises and then falls, so try a quadratic. On a TI-84, turn on stat diagnostics first or is not shown.
- Quadratic regression gives and
- Interpret: about of the variation in the germination percentage is accounted for by the quadratic model in temperature.
- Compare: a linear model gives . A straight line accounts for almost none of the variation, although the relationship is strong. It just isn't linear.
Where comes from (useful for understanding; the exam does not test this formula). Compare with the total variation of about its mean :
is the of the flat model , which ignores completely. If every point lies on the curve, , so .
Choosing between models
A high says the curve is close to the points you have. It doesn't say the model suits the situation, or that predictions outside the data can be trusted.
Before you trust a model, check: 1. Context. Does it behave sensibly? Sales can't be negative, and a cooling drink levels off at room temperature.
2. Extrapolation. A prediction outside the range of the data assumes the pattern carries on. Quadratic and cubic models often turn sharply just outside the data.
3. Extra terms. On the same data a cubic never has a lower than a quadratic, because a quadratic is a cubic with . So a slightly higher from a cubic is weak evidence.
4. Like with like. For exponential and power regression your GDC fits a straight line to , and the it shows belongs to that line. Don't rank it directly against a quadratic's .
Try it first, then reveal one step at a time.
- Quadratic regression gives , with : a very close fit to weeks to .
- At : , so about thousand.
- Comment: that is about times the week sales. The quadratic has its minimum near and rises after it, but a game's sales don't climb back like this.
- Week is far outside the data, so this is an extrapolation. Exponential regression gives , which keeps falling (about thousand in week ): a more sensible long-term shape.
Try it first, then reveal one step at a time.
- A cubic is a quadratic plus one extra term, so on the same data its is never lower. A rise from to is no real evidence.
- The cubic predicts m at years: impossible. The quadratic predicts m, shorter than the tree was at : also impossible.
- Age is far outside the data ( to years), so both predictions are extrapolations. Trees slow down and level off, so a model that levels off would suit the context better.
- Not a good choice: a cubic's is never lower than a quadratic's on the same data, and at years both models extrapolate to impossible heights.
Common mistakes
- Fitting the wrong model: linear regression on curved data, or against when the question asks for against . Use the form and variables the question names.
- Working out a residual as predicted minus observed. A residual is observed minus predicted, so a point above the curve has a positive residual.
- Rounding parameters to 2 s.f., or using rounded parameters for later predictions. Give 3 s.f. and use the GDC's stored values.
- Stating which model is better with no reason. Quote both values ( or ), compare them, and add a reason from the context.
- Ignoring a known added constant. For , subtract from the -values before running exponential regression.
- Trusting a high far outside the data. Check what the model predicts there and whether it makes sense.
Exam tips
- Find the model: write which regression you ran, then the equation with each parameter to 3 s.f., using the question's variables (such as and , not and ).
- Find : show the predicted values and the sum of squared differences before the final value. Those lines earn the method marks.
- Interpret : say what proportion of the variation in the named variable the model accounts for, such as 'about of the variation in rent'.
- Justify which model is better: compare the two values, then give a reason from the context, such as long-term behaviour. A choice with no reason earns no marks.
Key takeaways
Practise this
15 past-paper questions on Non-linear regression and linearizing in the AI HL bank, each with a mark scheme and a worked explanation.