Non-linear regression AI HL

Non-linear regression fits a curve instead of a straight line to paired data. You choose the type of curve from the scatter diagram and the context, the calculator finds the equation and the coefficient of determination, and you use the model to predict and to judge how far it can be trusted. A high coefficient of determination never settles the choice on its own, so every fit needs a sense check against the context.

Formulas at a glance

Only the linear regression line and the range of the correlation coefficient appear in the formula booklet. The non-linear forms below are not in the booklet: the calculator supplies the coefficients, but you must know which form belongs to which model and how to read its coefficients.

Linear regression line

y=ax+by=ax+b

In the booklet

Pearson correlation coefficient (linear data only)

−1≤r≤1-1\le r\le1

In the booklet

Quadratic model

y=ax2+bx+cy=ax^2+bx+c

Not in the booklet

Cubic model

y=ax3+bx2+cx+dy=ax^3+bx^2+cx+d

Not in the booklet

Exponential model

y=abxy=ab^x

Not in the booklet

Power model

y=axby=ax^b

Not in the booklet

Sine model

y=asin⁡(bx+c)+dy=a\sin(bx+c)+d

Not in the booklet

Coefficient of determination (any model)

0≤R2≤10\le R^2\le1

Not in the booklet

Which method to use

Plot the data first and decide which family of curve matches the pattern and the context, then let the calculator find the coefficients.

The question hasUseNotes
Points that rise then fall (or fall then rise) onceQuadratic regression, y=ax2+bx+cy=ax^2+bx+cOne turning point. The sign of aa shows whether it is a maximum or a minimum
Points with two turning points, or an S-shaped curveCubic regression, y=ax3+bx2+cx+dy=ax^3+bx^2+cx+dFour coefficients, so a good fit is easier to get and a poor prediction is easier to make
A quantity multiplied by a constant factor for each equal step in xxExponential regression, y=abxy=ab^xb>1b>1 is growth and 0<b<10<b<1 is decay. aa is the value at x=0x=0
A quantity that varies as a power of another, such as area against lengthPower regression, y=axby=ax^bThe curve passes through the origin when b>0b>0, and needs positive values of xx and yy
Data that repeat in a regular cycleSine regression, y=asin⁡(bx+c)+dy=a\sin(bx+c)+dThe calculator may not give R2R^2 for a sine fit, so judge it from the graph and the context
Two or more models that both fit wellCompare R2R^2, then the shape and the contextThe highest R2R^2 does not decide the choice. R2R^2 alone is not a good way to choose between models
A prediction for a value of xx outside the dataSubstitute into the model and comment on reliabilityPredictions beyond the data are unreliable, because the curve may not keep the same shape

AHL4.13

Non-linear regression

Non-linear regression fits a curve rather than a line to bivariate data, and the coefficient of determination R2R^2 measures the proportion of the variability in yy accounted for by the model. You choose a model type that matches the scatter diagram, use technology to find its equation, and compare models using R2R^2 together with the context.

Choosing a model

The forms of the quadratic, cubic, exponential, power and sine models are in the formulas at the top of the page. They are not in the formula booklet, so learn which pattern in the data belongs to which form. The calculator then supplies the coefficients and the coefficient of determination R2R^2.

Key terms

What is a regression curve?

A regression curve is the curve of a chosen type that best fits the data, found by least squares: its coefficients make the sum of the squares of the residuals, SSresSS_{res}, as small as possible. Technology gives the values of its coefficients, and a smaller SSresSS_{res} means a closer fit for that model.

e.g. Fitting a quadratic gives an equation of the form y=ax2+bx+cy=ax^2+bx+c, where technology supplies aa, bb and cc.

How do you choose the type of model?

Look at the scatter diagram and the context. Growth by a constant factor suggests an exponential model, repeating cycles suggest a sine model, and a single turning point suggests a quadratic.

e.g. A population that doubles every year suits y=abxy=ab^{x}, while the height of a thrown ball over time suits y=ax2+bx+cy=ax^2+bx+c.

How is R-squared related to r for a linear model?

For a linear model, R2R^2 equals r2r^2, the square of Pearson's correlation coefficient. For other types of model, rr is not used.

e.g. If r=−0.9r=-0.9, then R2=(−0.9)2=0.81R^2=(-0.9)^2=0.81.

Why can a model with a higher R-squared still be a poor choice?

R2R^2 only measures how well the model fits the given data. A model can fit well and still behave unrealistically outside the data, so the context must be considered as well.

e.g. A downward-opening quadratic fitted to a plant's growth might have R2=0.95R^2=0.95 yet predict negative heights later on.

Worked example, step by step

The question Calculator needed [6 marks]

A farmer applies different amounts of fertiliser to six identical plots of land. For xx tens of kilograms of fertiliser per hectare, the yield is yy tonnes per hectare.

xx: 2, 4, 6, 8, 10, 12
yy: 3.2, 4.8, 5.3, 5.9, 5.3, 4.4

The yield is modelled by y=ax2+bx+cy=ax^2+bx+c.

(a) Use regression to find the values of aa, bb and cc, correct to 3 significant figures.

(b) Write down the value of R2R^2.

(c) Use the model to find the amount of fertiliser, in kilograms per hectare, that gives the greatest yield.

Worked solution: worked example

Answer: (a) a=−0.0754a=-0.0754, b=1.17b=1.17, c=1.19c=1.19 (b) R2=0.979R^2=0.979 (c) 77.777.7 kilograms per hectare

Step 1 - Choose the model and enter the data.

Enter the xx-values in one list and the yy-values in a second list. The scatter diagram rises and then falls once, so the question's quadratic model y=ax2+bx+cy=ax^2+bx+c is sensible. Choose quadratic regression and run it on the two lists.

Why? The shape of the data and the context both suggest one turning point, which is what a quadratic gives. The calculator then finds the curve that makes the sum of the squares of the residuals as small as possible.

Step 2 - Read the coefficients.

The calculator gives a=−0.0754a=-0.0754, b=1.17b=1.17 and c=1.19c=1.19 to 3 significant figures, so y=−0.0754x2+1.17x+1.19.y=-0.0754x^2+1.17x+1.19. A1 - a=−0.0754a=-0.0754 A1 - b=1.17b=1.17 A1 - c=1.19c=1.19

Why? Each value is read straight from the regression output. The negative value of aa agrees with a curve that has a maximum.

Step 3 - Read the coefficient of determination.

With diagnostics switched on, the output also gives R2=0.979R^2=0.979. A1 - R2=0.979R^2=0.979

Why? This means about 97.9%97.9\% of the variability in the yield is accounted for by the model. It shows the quadratic fits these six plots closely, but R2R^2 alone does not prove the model is the best choice or reliable outside the data.

Step 4 - Find the greatest yield.

Graph the regression equation, with the unrounded coefficients stored by the calculator, and use the maximum tool on the graph. The maximum is at x=7.77x=7.77, where y=5.74y=5.74. M1 - Find the maximum point of the model (graph and maximum, or x=−b2ax=-\dfrac{b}{2a})

Why? The greatest yield is the maximum point of the model. The xx-coordinate is the amount of fertiliser. Using the stored unrounded equation avoids a rounding error from the 3 significant figure coefficients.

Step 5 - Convert to the units asked for.

The value of xx is in tens of kilograms, so the amount of fertiliser is 7.77×10=77.77.77\times10=77.7 kilograms per hectare. A1 - 77.777.7 kilograms per hectare

Why? The question asks for kilograms per hectare, not tens of kilograms, so the answer is converted at the end.

Marks (6):
A1 a=−0.0754a=-0.0754
A1 b=1.17b=1.17
A1 c=1.19c=1.19
A1 R2=0.979R^2=0.979
M1 Find the maximum point of the model (graph and maximum, or x=−b2ax=-\dfrac{b}{2a})
A1 77.777.7 kilograms per hectare

Now you try: enter your answers to be marked

These are real practice questions. Type your answer in each box and press Mark it. The worked solution and mark scheme appear straight away, and your first attempt is the one that counts. Use the keyboard for powers, roots and trig, and the working box for your notes.

1
Medium
Calculator
[4 marks]
Use your calculator to fit a power model y=axny=ax^n to the data in the table.

xx2468
yy5.220.846.883.2
(a) State the value of a.a.
[2]
(b) State the value of n.n.
[1]
(c) State the value of the coefficient of determination R2.R^2.
[1]
Fractions & powers
Other

Worked solution: practice question 1

2
Hard
Calculator
[5 marks]
The table shows distance dd (m) braked in time tt (s).
tt12345
dd1.24.59.114.821.0

A model in the form d=at3+bt2+ct+ed = at^3 + bt^2 + ct + e can be created to fit this data.
(a)(i) State a,a, to 3 decimal places.
[1]
(a)(ii) State b,b, to 3 decimal places.
[1]
(a)(iii) State c,c, to 3 decimal places.
[1]
(a)(iv) State e,e, to 3 decimal places.
[1]
(b) State R2.R^2.
[1]
Fractions & powers
Other

Worked solution: practice question 2

3
Medium
Calculator
[5 marks]
Use technology to fit an exponential model y=abxy=ab^x to the data below.

xx01234
yy510204080
(a) Find the value of a.a.
[2]
(b) Find the value of b.b.
[1]
(c) Use the model to predict yy when x=5.x=5.
[2]
Fractions & powers
Other

Worked solution: practice question 3

Your score so far: 0 out of 14 marks

Common mistakes

  • Quoting rr for a non-linear model. Pearson's rr only measures linear correlation - for quadratic, exponential or power models, compare fits using R2R^2 instead.
  • Treating the highest R2R^2 as automatically "correct". A model with more parameters (cubic over quadratic, say) can chase individual data points rather than the underlying trend - always sanity-check the shape against the scatter diagram too.
  • Extrapolating a curved model far beyond the data. An exponential or power curve can shoot off to unrealistic values outside the range it was fitted on, even when R2R^2 inside that range is excellent.

Try some questions on non-linear regression

Using your GDC

The exact key presses for the TI-84 Plus CE, Casio fx-CG50, Casio fx-CG100 and TI-Nspire CX, with what the screen shows. Pick your calculator.

Make a scatter diagram

Used in: Non-linear regression

How to make a scatter diagram on a TI-84 Plus CE

Scatter plot from two lists (STAT PLOT)

If L1 and L2 already hold data, press stat, choose 4:ClrList, then press 2nd 1 (L1) , 2nd 2 (L2) and enter to empty them.

ClrList L1,L2

Press stat, choose 1:Edit and press enter. Type the x-values into L1, pressing enter after each: 2, 3, 5, 6, 8, 9, 11, 12. Press ▶ to move to L2 and type the y-values in the same order: 31, 38, 40, 52, 55, 63, 60, 74. The two lists must have the same number of values.

L1    L2    L3
2     31    ---
3     38    ---
5     40    ---
6     52    ---
8     55    ---
9     63    ---
11    60    ---

Press 2nd Y= (STAT PLOT), choose 1:Plot1 and press enter. Highlight On and press enter. Check that Type is the first icon (scatter plot), Xlist is L1 and Ylist is L2. If not, move to the item, press enter to choose the icon, or type the list name with 2nd 1 (L1) or 2nd 2 (L2).

Plot1
On  Off
Type: scatter (first icon)
Xlist:L1
Ylist:L2

Press zoom and choose 9:ZoomStat. The calculator sets the window to fit the data and draws the scatter plot. Press trace and ◀ ▶ to move from point to point and read each pair of values.

The points rise from the lower left to the upper right: as x increases, y increases.

When you have finished, press 2nd Y= (STAT PLOT) and choose 4:PlotsOff. A plot left on makes the next function graph fail with an error.

The full guide: Make a scatter diagram

Fit a model (quadratic, cubic, exponential, power, sinusoidal)

Used in: Non-linear regression

How to fit a model on a TI-84 Plus CE

Turn on R² (once)

R² stays hidden until diagnostics are switched on. Open the mode screen with mode, go down to the STAT DIAGNOSTICS line, choose ON with ▶ and confirm with enter. Leave with 2nd mode (QUIT). The setting lasts until the calculator is reset.

Enter the data

Open the list editor with stat and 1:Edit. To empty a list, highlight its name (L1 or L2) at the top and press clear, then enter.

Key the inputs into L1 one per line, with enter after each: 0, 1, 2, 3, 4, 5, 6, 7. Move across to L2 with ▶ and key the outputs the same way: 12, 18, 25, 36, 49, 70, 98, 141. The two lists need equal lengths.

L1 = 0, 1, 2, 3, 4, 5, 6, 7
L2 = 12, 18, 25, 36, 49, 70, 98, 141
Choose the model and run it

Press stat and move to CALC with ▶. The curve fits are numbered in the menu:

5:QuadReg quadratic, y=ax2+bx+cy = ax^2 + bx + c
6:CubicReg cubic, y=ax3+bx2+cx+dy = ax^3 + bx^2 + cx + d
0:ExpReg exponential, y=abxy = ab^x
A:PwrReg power, y=axby = ax^b
C:SinReg sinusoidal, y=asin⁡(bx+c)+dy = a\sin(bx + c) + d

For the example choose 0:ExpReg. With the Stat Wizards on, a screen asks for Xlist and Ylist: set Xlist to L1 and Ylist to L2 (press 2nd 1 for L1 and 2nd 2 for L2), then move to Calculate and press enter. If the Stat Wizards are off, type ExpReg L1,L2 and press enter.

ExpReg
y=a*b^x
a=12.4068849
b=1.4142966
r²=0.9994408
r=0.9997204

Read a and b, and r² (the R² value). The same steps work for the other models; only the menu item changes.

y=12.4×1.41xy = 12.4 \times 1.41^{x} and R2=0.9994R^2 = 0.9994, with the coefficients to 3 significant figures.

Compare two models with R²

Run another model on the same lists: press stat, ▶ to CALC and choose 5:QuadReg, with Xlist L1 and Ylist L2 as before. The screen shows a, b, c and R². Compare the R² values of the models, then look at the graph before you decide.

y=2.84x2−2.60x+15.5y = 2.84x^2 - 2.60x + 15.5 and R2=0.9937R^2 = 0.9937.

QuadReg
y=ax²+bx+c
a=2.8392857
b=-2.6011905
c=15.5416667
R²=0.9936753
Predict a value from the model

Before you run the regression, move to Store RegEQ on the wizard screen, press vars, then ▶ to Y-VARS and choose 1:Function then 1:Y1. The full-accuracy equation is then saved in Y1. On the home screen type Y1(4.5) and press enter.

y=59.0y = 59.0 when x=4.5x = 4.5 for the exponential model, to 1 decimal place.

Y1(4.5)
59.0330102
A sinusoidal model

Enter the times in L1 and the depths in L2 (clear the old values first): L1 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24; L2 3.1, 5.6, 7, 6.4, 3.9, 1.6, 1.3, 3.4, 5.9, 7.1, 6.2, 3.8, 1.9. Then press stat, ▶ to CALC and choose C:SinReg. Leave Period empty when the times are equally spaced and in order, otherwise type a period guess. Move to Calculate and press enter.

SinReg
y=a*sin(bx+c)+d
a=2.9173012
b=0.4526533
c=-0.3835108
d=4.2119403

The screen gives a, b, c and d and no R². The angle is always in radians, so put the calculator in radian mode before you use the stored equation.

y=2.92sin⁡(0.453x−0.384)+4.21y = 2.92\sin(0.453x - 0.384) + 4.21, with the coefficients to 3 significant figures.

If R² does not appear, diagnostics are off: turn STAT DIAGNOSTICS on in the mode screen and run the regression again. Use the stored equation in Y1 rather than rounded coefficients when you predict.

The full guide: Fit a model (quadratic, cubic, exponential, power, sinusoidal)

See the full list of GDC guides for every calculator task.

Syllabus content covered

CodeSyllabus content
AHL4.13Non-linear regression. Evaluation of least squares regression curves using technology. In examinations, questions may be asked on linear, quadratic, cubic, exponential, power and sine regression. Sum of square residuals (SSresSS_{res}) as a measure of fit for a model. The coefficient of determination (R2R^2). R2R^2 gives the proportion of variability in the second variable accounted for by the chosen model. Evaluation of R2R^2 using technology. Awareness that many factors affect the validity of a model and the coefficient of determination, by itself, is not a good way to decide between different models.

Official IB source: Mathematics: applications and interpretation subject brief (PDF, ibo.org).

Quick questions

Which non-linear regression models can I fit on my calculator?

A calculator can fit quadratic, cubic, exponential, power and sine regression curves from its statistics menu, alongside the usual linear regression option.

How do I know whether to use an exponential or a power model?

In an exponential model y=abxy=ab^{x}, yy is multiplied by a constant factor for each equal increase in xx. In a power model y=axby=ax^{b}, yy varies as a power of xx, such as area against length. Use the scatter diagram and the context to decide.

Is it safe to predict outside the range of the data?

Predictions beyond the range of the data are unreliable, because the curve may not keep the same shape. Predictions inside the range are more trustworthy.

When would I use a sine model?

Use it when the data repeat in a regular cycle, such as the height of the tide or the hours of daylight through a year. The fitted equation has the form y=asin⁡(bx+c)+dy=a\sin(bx+c)+d.

Ready to practise properly?

Practice questions on every section, marked instantly like the real exam.