All revision notes topics

Least squares regression and residualsEdexcel A-Level Further Maths: Revision notes

Section 1

The least squares regression line

The least squares regression line of yy on xx is the line y=a+bxy=a+bx that minimises the sum of the squares of the residuals, the vertical distances from the points to the line. yy is the response variable and xx the explanatory variable, and the line should be used to predict yy from xx (not the other way round). The derivation is not required; you must use the formulae. Sxx=∑x2−(∑x)2n,Syy=∑y2−(∑y)2n,Sxy=∑xy−∑x∑yn.S_{xx}=\sum x^2-\frac{(\sum x)^2}{n},\quad S_{yy}=\sum y^2-\frac{(\sum y)^2}{n},\quad S_{xy}=\sum xy-\frac{\sum x\sum y}{n}.

Key termsleast squaresregression lineresponse variable
Common mistake

Using the line of yy on xx to predict xx from yy. A different line is needed for that.

Section 2

Calculating the coefficients

b=SxySxx,a=yˉ−bxˉ.b=\frac{S_{xy}}{S_{xx}},\qquad a=\bar y-b\bar x. The line always passes through (xˉ,yˉ)(\bar x,\bar y). Worked example: n=6n=6, ∑x=114\sum x=114, ∑y=342\sum y=342, ∑x2=2236\sum x^2=2236, ∑xy=6750\sum xy=6750. Then Sxx=2236−11426=70S_{xx}=2236-\frac{114^2}{6}=70 and Sxy=6750−114×3426=252S_{xy}=6750-\frac{114\times342}{6}=252, so b=3.6b=3.6. With xˉ=19\bar x=19 and yˉ=57\bar y=57, a=57−3.6×19=−11.4a=57-3.6\times19=-11.4, so y=−11.4+3.6xy=-11.4+3.6x. The gradient bb is the average change in yy for each unit increase in xx; the intercept aa is the predicted yy when x=0x=0, which may not be meaningful.

Key termsgradientintercept
Exam tip

Compute SxxS_{xx} and SxyS_{xy} separately first and write them down; they also feed the RSS.

Section 3

Residuals

A residual is the difference between an observed value and the value predicted by the line: residual=yi−y^i=yi−(a+bxi).\text{residual}=y_i-\hat y_i=y_i-(a+bx_i). A positive residual means the point is above the line; a negative residual means it is below. Residuals from a least squares line always sum to zero. Example: for y=3+2.2xy=3+2.2x, the observation (6,15)(6,15) has y^=16.2\hat y=16.2, so the residual is 15−16.2=−1.215-16.2=-1.2.

Key termsresidualpredicted value
Common mistake

Subtracting the other way round. Residual is observed minus predicted.

Section 4

Residual sum of squares

The residual sum of squares is the quantity that least squares minimises: RSS=∑(yi−y^i)2=Syy−(Sxy)2Sxx.\text{RSS}=\sum(y_i-\hat y_i)^2=S_{yy}-\frac{(S_{xy})^2}{S_{xx}}. A small RSS relative to SyyS_{yy} means the line fits well. Example: Syy=920S_{yy}=920, Sxy=252S_{xy}=252, Sxx=70S_{xx}=70 gives RSS=920−907.2=12.8\text{RSS}=920-907.2=12.8. Because it is a sum of squares, RSS is never negative; the formula's second term can never exceed SyyS_{yy}.

Key termsresidual sum of squares

Section 5

Checking the fit and outliers

Use residuals to judge whether a linear model is reasonable. If they are small and show no pattern (a mixture of positive and negative), a linear fit is sensible. A run of positive then negative then positive residuals suggests curvature, so a different model may be needed. One residual much larger than the rest marks a possible outlier. To refine a model, investigate the outlier. If there is a reason (a misreading, a recording error), remove it and recalculate the line and RSS. Example: removing a point with residual 66 from seven points cut the RSS from 4646 to 44. Do not remove a point only because it spoils the fit.

Key termsoutlier
Exam tip

In a comment, name the residual and the change in RSS, then link them to the model.

Section 6

Using and interpreting the line

Predicting yy for an xx inside the data range is interpolation and is usually reliable. Predicting outside the range is extrapolation and may be wildly wrong, because the relationship may not stay linear. Always interpret the gradient in context: 'for each extra hour of revision the score increases by 4.34.3 marks, on average'. Check that predictions make sense (for example, a test score over the maximum is impossible).

Key termsinterpolationextrapolation

That's the notes covered.

Carry on to the next subtopic.

Exam questions on Least squares regression and residuals

  1. A researcher models the relationship between a variable xx and a variable yy using the least squares regression line of yy on xx, y=a+bxy=a+bx. Summary statistics from the data give xˉ=5\bar x=5, yˉ=14\bar y=14, Sxx=40S_{xx}=40 and Sxy=88S_{xy}=88.
    One observation is x=6x=6, y=15y=15. Calculate the residual for this observation.2 marks
  2. A student records the number of hours, xx, spent revising and the score, yy, out of 40, on a test for 5 students: (1,12)(1,12), (2,15)(2,15), (3,21)(3,21), (4,22)(4,22), (5,30)(5,30). The summary statistics are n=5n=5, ∑x=15\sum x=15, ∑y=100\sum y=100, ∑x2=55\sum x^2=55, ∑xy=343\sum xy=343 and ∑y2=2194\sum y^2=2194.
    The regression line is y=7.1+4.3xy=7.1+4.3x. Interpret the value 4.34.3 in context, and explain why the line should not be used to predict the score of a student who revises for 15 hours.2 marks
  3. A café owner records the midday temperature, x ∘x\,^\circC, and the number of cold drinks sold, yy, on six days: (14,40)(14,40), (16,45)(16,45), (18,55)(18,55), (20,58)(20,58), (22,68)(22,68), (24,76)(24,76). The summary statistics are n=6n=6, ∑x=114\sum x=114, ∑y=342\sum y=342, ∑x2=2236\sum x^2=2236, ∑xy=6750\sum xy=6750 and ∑y2=20414\sum y^2=20414.
    Find the equation of the regression line of yy on xx.3 marks
See the full worksheet

Written by the Exaim team, led by Shaun Daswani (Head of Upper Secondary, Improve ME Institute; MSc Financial Mathematics, Imperial College London; BSc, UCL) and Jason Daswani (operational lead, Improve ME Institute; LSE).