A Level Further Mathematics · Chapter 46 · Further Statistics · Further Statistics 2
A regression line is the straight line that makes the squared vertical distances from the data as small as possible.
When two quantities seem to move together, a straight line can summarise the relationship and make predictions. This chapter finds the best such line by least squares, measures how well it fits through residuals, and shows how to work with coded data.
In this chapter · jump to a section
Start here
Your route through this chapter
By the end of this chapter you will be able to:
- calculate , and from raw data or from summary totals
- find the least squares regression line of on and interpret its coefficients
- use the line for prediction, and judge when a prediction is reliable
- calculate residuals and use a residual plot to spot outliers and poor fits
- find the residual sum of squares from
- find a regression line from coded data and convert it back
Time: three sessions, about 4 hours, plus the practice ladder and the exam workshop.
You need first: scatter diagrams, the equation of a straight line, means, and differentiation for the proof workshop.
The big idea
The big idea
For each data point, the vertical gap between the observed value and the value on a line is a residual. The least squares line chooses its gradient and intercept to make the sum of the squared residuals as small as possible. The result is
The diagram shows a café's sales of cold drinks on eight days at different temperatures. The points rise roughly in a straight line, and the regression line summarises that trend. Every least squares line passes through the mean point , marked on the diagram.
Explanatory and response variables
In a regression, one variable is used to predict the other. The explanatory variable, , is the one we know or control, such as temperature. The response variable, , is the one we want to predict, such as sales. The choice matters, because the line of on is designed for predicting and is not the right line for predicting .
Why squares?
A residual can be positive or negative, so simply adding them lets errors cancel. Squaring makes every contribution positive, and it penalises large errors more than small ones. Squares also make the algebra work neatly, because a sum of squares can be minimised with calculus. That is why the method is called least squares.
Vertical, not perpendicular
The residuals are measured vertically, parallel to the -axis. That matches the purpose of the line: for a given , it predicts , and the error in that prediction is vertical. Measuring perpendicular distances would give a different line, which treats both variables alike but is not suited to prediction.
Regression and causation
A good regression line shows that two variables are linked, not that one causes the other. Ice cream sales and drowning incidents both rise in hot weather, but neither causes the other. A regression can still be useful for prediction, as long as the underlying conditions do not change.
Section 1
Summary statistics
Sums of squares and products
Three summary statistics measure the spread of the data and how the variables vary together:
They equal , and , but the forms above are easier to calculate.
Common mistake: using the sum of x squared as Sxx, without subtracting the square of the total over n. The correction term measures the data from their mean rather than from zero. Leaving it out gives a value that depends on where the origin is, which makes the gradient wrong.
What Sxy measures
Each term is positive when a point lies above and to the right of the mean point, or below and to the left. It is negative in the other two quadrants. So is large and positive when the points rise together, negative when one falls as the other rises, and near zero when there is no linear pattern.
Sxx and Syy are never negative
Since is a sum of squared deviations, it can never be negative. It is zero only when every -value is the same. The same holds for . A negative value therefore signals an arithmetic error, usually a missing correction term or a mistake in .
Working from summary totals
Examination questions often give totals such as , and rather than the raw data. Substitute them carefully into the formulas. Keep full calculator accuracy in and , because rounding them early can change the gradient noticeably.
Units of the statistics
If is in degrees and in drinks, then is in degrees squared and in degree-drinks. The gradient is then in drinks per degree, which is exactly what a gradient should mean. Thinking about units is a quick check that a formula has been set up correctly.
Calculator statistics modes
Most calculators have a statistics mode that computes the totals and the regression coefficients directly. Use it to check your working, but show the formulas in an examination. A question that asks you to find expects to see the calculation, not just the answer.
Why two forms of each formula?
The deviation form, such as , shows what the statistic means. The computational form, using totals, is quicker and less prone to rounding errors, because it avoids subtracting a rounded mean from every value. Use the deviation form to understand and the computational form to calculate.
Checking a total
Before using a total in a formula, check it if you can. For raw data, add the values twice or use the calculator's statistics mode. An error in a total spreads into every later result. A few seconds spent checking prevents a whole question going wrong.
The size of Sxy compared with Sxx
The gradient is the ratio of these two numbers. If is about twice , the gradient is about two. This gives a quick estimate before any exact calculation, and a way to spot errors. A gradient that seems far too large or small often comes from a slip in one of the totals.
Paired data
Regression needs paired data: each -value must go with its own -value from the same day, person or object. Mixing up the pairs destroys the relationship. When reading data from a table, keep each pair together, and check that there are equally many -values and -values.
Worked example 1: from raw data
For the eight days in the big idea, , , and . Find and .
| Working | Reason |
|---|---|
| Subtract the square of the total over n | |
| Subtract the product of the totals over n | |
| Evaluate the difference to get Sxy |
Large totals and rounding
Totals such as can be very large, while may be small. The subtraction then loses accuracy if the totals are rounded. Always use the exact totals given in a question. If you calculate totals yourself, keep every digit until the subtraction is done.
Worked example 2: from totals
For ten pairs, , , and . Find and .
| Working | Reason |
|---|---|
| Use the formula with the given totals | |
| Substitute the totals into the product formula | |
| Evaluate the difference to get Sxy |
Check yourself. Five points , , , and have . Find .
Show the answer
The total of the -values is 30, so . Without the correction term the answer would be 220, far too large.
Section 2
The least squares regression line
The formulas
The least squares regression line of on is , where
The gradient comes first, then the intercept, which forces the line through the mean point.
Common mistake: dividing Sxy by Syy instead of Sxx. The line of on measures errors vertically, so the gradient is . Dividing by belongs to a different line, for predicting from , and gives the wrong gradient for predicting .
Least squares: the line that makes the squared residuals smallest
- Your line
- y = 5.48 + 1.54x
- Your RSS
- 117.78
- Least squares line
- y = −5.12 + 1.94x
- Least squares RSS
- 18.9
Figure 46.1 lets you move a line and watch the squared residuals change. The least squares line gives the smallest total; the wrong model's line, using , does much worse.
The line passes through the mean point
Substituting into gives . So the least squares line always passes through . This is a useful check on any calculated line, and it helps when drawing the line on a scatter diagram.
Order of calculation
Find the means and the summary statistics first. Then calculate the gradient, and only then the intercept. Using a rounded gradient in the intercept can change the intercept noticeably, so keep the full value in the calculator. Give the final coefficients to three significant figures unless told otherwise.
Why the method is called regression
The word comes from studies of the heights of parents and children. Very tall parents tended to have children who were tall, but less extremely so. The heights seemed to move back, or regress, towards the average. The name stuck for the whole method of fitting lines to data, even when nothing regresses.
A different line for each purpose
Predicting from needs the regression line of on , which minimises horizontal distances. It is generally a different line from the one of on . The two lines meet at the mean point. They coincide only when every point lies exactly on a straight line.
Writing the equation
State the line in the context, using the names of the variables. For example, write sales temperature, or define and clearly. Writing just with numbers is acceptable, but a reader then needs to know what and stand for.
A line for each data set
Every data set has its own regression line. Adding or removing a point changes the means and the summary statistics, and so changes the line. This is why the data used should be stated alongside the line. A line from one café's data may not suit another café with different customers.
Thinking about the scatter diagram first
Always look at a scatter diagram before fitting a line. If the points do not follow a roughly straight pattern, a regression line may mislead. A diagram also shows any unusual points that might affect the line. In examinations, a sketch is sometimes asked for, and it is always useful.
What the least squares line does not do
The least squares line does not pass through any particular data point, and it does not try to. It balances all the points at once. Some points lie above it and some below. A line that passes exactly through two chosen points will usually have a larger residual sum of squares.
Worked example 3: the drinks line
Find the regression line of on for the drinks data, with , , and .
| Working | Reason |
|---|---|
| Divide Sxy by Sxx for the gradient | |
| Use the mean point to find the intercept | |
| Write the line to three significant figures |
The gradient's sign
A positive gradient means tends to increase with , and a negative gradient means it tends to decrease. The sign of the gradient always matches the sign of , because is positive. So the sign can be predicted from the scatter diagram before any calculation, which makes a quick check.
Worked example 4: from totals
Using the totals in worked example 2, find the regression line of on .
| Working | Reason |
|---|---|
| Divide Sxy by Sxx for the gradient | |
| , , so | Find the intercept from the means |
| State the regression line |
Check yourself. Work out the regression line for the points in the check-yourself of section 1, given and .
Show the answer
The gradient is , and the means are 6 and 15. So the intercept is , giving the line .
Section 3
Interpreting the line and predicting
The gradient and intercept in context
The gradient tells you how much changes, on average, for each unit increase in . In the drinks example, each extra degree goes with about 1.94 more drinks sold. The intercept is the predicted value of when , which may or may not make sense in context.
Common mistake: trusting predictions made far outside the range of the data. The line describes the data that were collected. Beyond that range the relationship may change, so extrapolated predictions can be badly wrong. Predictions within the range, called interpolation, are much more reliable.
A negative intercept
In the drinks example the intercept is about , which would mean negative sales at zero degrees. That is impossible. It shows that the line should not be used far outside the range of temperatures observed. The intercept is a mathematical part of the line, not always a meaningful prediction.
How reliable is a prediction?
A prediction is more reliable when the points lie close to the line and there are many data points. It is also more reliable when the -value is near the middle of the data. Predictions near the ends of the range are less certain. A residual plot, studied in section 4, helps judge how close the points lie to the line.
Predicting x from y
The line of on is designed for predicting . Rearranging it to predict from a given is not strictly correct, although it is sometimes done when the points lie very close to the line. If a question asks for given , consider whether the regression of on would be more appropriate.
When a straight line is wrong
Some relationships are curved. A straight line through curved data gives systematic errors: too high in the middle and too low at the ends, or the reverse. Looking at the scatter diagram before fitting a line, and at the residuals afterwards, reveals whether a straight line is suitable.
Reporting a prediction
Give a prediction with sensible accuracy and a comment on its reliability. For example, at 19 °C the line predicts about 32 drinks, and this is reliable because 19 °C is inside the data range. A prediction at 40 °C would be extrapolation and should be treated with great caution.
Random variation about the line
Even within the data range, individual values vary around the line. The line predicts an average value of for a given . On any particular day, sales will be higher or lower than predicted, because of factors not included in the model. The residuals show how large this variation typically is.
Using more than one variable
Sales might depend on temperature, day of the week and whether there is an event nearby. A simple regression uses only one explanatory variable. Other factors add to the residual variation. More advanced methods use several explanatory variables at once, but they build on the same least squares idea.
Worked example 5: interpolation
Use the drinks line to predict sales at 19 °C, and comment on the reliability.
| Working | Reason |
|---|---|
| Substitute the temperature into the line | |
| , so about 32 drinks | Evaluate and round to a whole number |
| Reliable: 19 °C lies inside the data range | Check whether this is interpolation |
Average change, not exact change
The gradient describes the average change in for each unit of . It does not say that every unit increase in produces exactly that change. Real data scatter around the line. Phrases such as "on average" or "tends to" make an interpretation accurate and earn credit in examinations.
Worked example 6: interpreting the gradient
Using the line from worked example 4, , predict when and interpret the gradient.
| Working | Reason |
|---|---|
| Substitute into the regression line | |
| Each unit increase in x adds about 3.27 to y on average | Interpret the gradient in words |
| Reliable if 7 lies inside the observed x-values | Comment on whether this is interpolation |
Check yourself. Explain why a prediction at 40 °C from the drinks line, 72.5 drinks, is unreliable.
Show the answer
The temperatures observed ran only from 12 °C to 26 °C, so 40 °C is far outside the data. The relationship may change in extreme heat, so the prediction of 72.5 drinks is extrapolation and cannot be trusted.
Section 4
Residuals
Definition
The residual for a data point is the observed value minus the value predicted by the line:
A positive residual means the point lies above the line; a negative one means it lies below.
Common mistake: calculating each residual as the predicted value minus the observed value. That reverses every sign, so points above the line appear to lie below it. A residual is what the line failed to explain in the observation, so it is always observed minus predicted.
Residuals and a residual plot
- Regression line
- y = −5.12 + 1.94x
- Residual at x = 22
- −1.57
- Sum of residuals
- 0
- Residual sum of squares
- 18.9
Figure 46.2 plots the residuals against and lets you move one point. The wrong model's residuals have every sign flipped.
Residual plots
A residual plot shows the residuals against . For a good linear fit, the residuals scatter randomly above and below zero with no pattern. A curved pattern suggests that a straight line is not suitable. A residual much larger than the others suggests a possible outlier, a point that does not follow the general trend.
The residuals add to zero
For the least squares line, the residuals always add up to zero. This follows from the fact that the line passes through the mean point. It is a useful check on residual calculations. If they do not add to roughly zero, something has gone wrong, perhaps a sign error or a slip in the line itself.
Dealing with outliers
An outlier may be a recording error, or it may be a genuine unusual case. If it is an error, it can be corrected or removed. If it is genuine, removing it hides real information. Either way, it is good practice to note the outlier and to see how much it changes the regression line.
Influence of a single point
A point far from the others in the -direction can pull the regression line strongly towards itself. Such a point is called influential. Its residual may even be small, because the line has moved to fit it. Comparing the line with and without the point reveals how influential it is.
Reading a residual plot in an examination
A question may show a residual plot and ask what it suggests. A random scatter means a linear model is suitable. A curve means it is not. A single large residual means a possible outlier. State the feature you see and what it means for the model, in one or two sentences.
Residuals and the model's assumptions
A linear model assumes that the points scatter randomly about a straight line, with similar spread everywhere. Residual plots check this assumption. If the spread of residuals grows with , the model's predictions are less reliable for large . Noticing such patterns is part of using regression responsibly.
When to remove a point
A point should not be removed just because it has a large residual. It should be removed only if there is a good reason to think it is an error, such as a mistake in recording. Removing genuine data to improve the fit misrepresents what was observed. Always report any point that has been removed and why.
Residuals in context
A residual has the same units as . A residual of 2 drinks means that day sold two more drinks than the line predicted. Interpreting residuals in context, such as noting that one day was unusually busy, links the mathematics back to the real situation it describes.
A residual plot by hand
To draw a residual plot, put on the horizontal axis and the residual on the vertical axis. Draw a horizontal line at zero. Plot one point for each pair. The plot needs no units on the vertical axis beyond those of , and it is easiest to read when the zero line runs through the middle.
Worked example 7: calculating residuals
For the drinks line , find the residuals at and , where and .
| Working | Reason |
|---|---|
| At 16: , residual | Observed minus predicted for the first point |
| At 18: , residual | Repeat for the second point |
| The first point lies below the line, the second above | Interpret the signs of the residuals |
Large residuals and influential points
A large residual shows a point that the line fits badly. An influential point may have a small residual, because the line bends towards it. So a residual plot alone may not reveal an influential point. Fitting the line with and without a suspicious point is the surest way to judge its effect.
Worked example 8: the residuals add to zero
For the five points , , , and , with line , find all the residuals.
| Working | Reason |
|---|---|
| Predicted: 6.6, 10.8, 15.0, 19.2, 23.4 | Substitute each x into the line |
| Residuals: 0.4, 0.2, −1.0, −0.2, 0.6 | Subtract each prediction from the observation |
| Their total is zero, as expected | Check using the property of least squares |
Check yourself. In worked example 8, which point lies furthest from the line, and on which side?
Show the answer
The point has the largest residual in size, . The negative sign means it lies below the line, by one unit.
Section 5
The residual sum of squares
A measure of fit
The residual sum of squares, , measures how far the points lie from the line overall. For the least squares line it can be found without calculating every residual:
A smaller RSS means a closer fit.
Common mistake: adding the residuals instead of their squares. For the least squares line the residuals always total zero, however good or bad the fit. Only the sum of the squared residuals measures how far the points lie from the line.
Derivation: the residual sum of squares
Write each residual using deviations from the means, since .
Square, add over all points and substitute .
So the residual sum of squares needs only the three summary statistics.
What RSS depends on
The RSS depends on the units of , so it cannot be compared across different data sets measured in different units. It also grows with the number of points. It is most useful for comparing different lines fitted to the same data, where the least squares line always gives the smallest value.
RSS and Syy
measures the total variation in . The term is the part explained by the line. The RSS is what remains unexplained. So the formula splits the variation in into an explained part and a residual part. When the line fits perfectly, the RSS is zero.
Using RSS to compare models
If two different models are fitted to the same data, the one with the smaller RSS fits more closely. This is one way to choose between a straight line and some other model. However, a more complicated model almost always reduces the RSS, so closeness of fit is not the only consideration.
Checking with individual residuals
For a small data set, the RSS can also be found by squaring and adding the residuals. The two methods should agree, apart from rounding. This is a good check in practice, and it shows that the formula really does measure the same thing.
Why the minimum is at Sxy over Sxx
For lines through the mean point, the RSS is a quadratic in the gradient, . Its minimum is at , found by completing the square or by differentiating. The diagram above shows this parabola for the drinks data. The proof workshop gives the full argument.
Comparing the explained and unexplained parts
For the drinks data, is 651.5 and the RSS is only about 18.9. So almost all of the variation in sales is explained by temperature. In a weaker relationship, the RSS would be a larger share of . This comparison leads naturally to the correlation coefficient in a later chapter.
Rounding and the RSS
The RSS is a difference between two numbers that may be close together. Rounding them early can produce a large relative error, or even a negative RSS. Keep full calculator accuracy in and until the final subtraction. Then round the RSS to a sensible number of figures.
A perfect fit
If every point lies exactly on a straight line, every residual is zero, and so is the RSS. Then , which means the correlation coefficient is exactly plus or minus one. Real data almost never fit perfectly, but very small RSS values show a strong linear relationship.
Worked example 9: RSS from summary statistics
For the drinks data, , and . Find the residual sum of squares.
| Working | Reason |
|---|---|
| Use the formula with the summary statistics | |
| Evaluate the explained part | |
| Subtract to leave the unexplained part |
RSS for a different line
The formula gives the RSS only for the least squares line. For any other line, the RSS must be found by squaring and adding its residuals directly. The proof workshop shows that every other line through the mean point has a larger RSS. The extra amount depends on how far its gradient is from the best one.
Worked example 10: checking with residuals
For the five points in worked example 8, find the RSS from the residuals and from the formula, given .
| Working | Reason |
|---|---|
| Square and add the residuals | |
| Use the formula with Sxy and Sxx | |
| Both methods give 1.6 | The two methods agree |
Check yourself. Using the totals in worked example 2, with , compute the RSS.
Show the answer
Substituting into the formula gives . Much of the variation in is explained by the line, but not all of it.
Section 6
Coded data
Why code?
Large or awkward numbers can be simplified by coding, such as and . The regression is calculated in the coded variables, and the result is converted back. Coding was essential before calculators, and it still appears in examination questions.
Common mistake: scaling the gradient but leaving the intercept in coded form. Substituting the coding into the coded line changes both coefficients. The origin of the coded scale is at , not , so the intercept must be recalculated.
Undoing coded data
- Coded line
- y = 38.657 + 4.114u
- Decoded line
- y = −2.486 + 0.4114x
- Line from raw data
- y = −2.486 + 0.4114x
Figure 46.3 lets you change the coding and see that the decoded line never changes. The wrong model keeps the coded intercept, which gives a line in the wrong place.
Decoding the line
If the coded line is , substitute and . Then rearrange to make the subject:
Always do this by substitution rather than by memorising the final formula.
Derivation: how coding changes the gradient
With , each deviation from the mean is divided by , so the summary statistics scale.
So the coded gradient is times the original gradient.
Dividing the coded gradient by therefore recovers the gradient in the original units.
Effects of coding on the statistics
Subtracting a constant does not change , or , because they measure deviations from the mean. Dividing by divides by and by . These effects combine to give the scaling of the gradient by . The intercept changes because the means change.
Choosing a coding
A good coding makes the numbers small and simple. Subtract a value near the middle of the data, and divide by the common gap between values if there is one. For the -values 105, 115, ..., 155, subtracting 100 and dividing by 10 gives 0.5, 1.5, ..., 5.5, which are much easier to work with.
Coding only one variable
Often only is coded, with left unchanged. Then and , and the decoding simplifies. Read the question carefully to see which variables have been coded, and how. A clear statement of the coding before you begin prevents mistakes later.
A check after decoding
After decoding, check that the line passes through the mean point of the original data. If the original means are known or easy to find, substitute into the decoded line and confirm that it gives . This catches most decoding errors quickly.
Coding and the residual sum of squares
If only is coded, the residuals are unchanged, because the fitted values for each point stay the same. So the RSS is unchanged too. If is scaled by , every residual is scaled by and the RSS by . Knowing this saves recalculation when coded data are used.
Coding in practice
Coding is still used when data have very large values, such as years like 2015, 2016 and 2017. Subtracting 2015 gives 0, 1 and 2, which are easier to handle and reduce rounding errors. The decoded line then refers to the actual years again. Calculators make coding less necessary, but the idea remains useful.
Writing the coding clearly
Before decoding, write down each coding as an equation, such as . Then substitute these equations into the coded line. Trying to adjust the coefficients mentally often leads to errors, especially with the intercept. A clear written substitution makes the method easy to follow and check.
Worked example 11: decoding a line
The values are coded by , and the regression of on is . Find the regression line of on .
| Working | Reason |
|---|---|
| Substitute the coding for u | |
| Expand the bracket and simplify | |
| Collect the constant terms |
Coding y as well as x
When is coded as , the coded line predicts , not . Substituting for and multiplying out turns it back into a prediction of . Forgetting to undo the coding of leaves the line predicting coded values, which are on the wrong scale entirely.
Predictions from a coded line
A prediction can be made either by decoding the line first or by coding the -value, predicting , and then decoding. Both give the same answer. Decoding the line first is usually clearer, especially when several predictions are needed. Choose one method and apply it consistently.
Worked example 12: coding both variables
With and , the coded line is . Find the line of on .
| Working | Reason |
|---|---|
| Substitute both codings into the line | |
| Multiply by ten and simplify | |
| Add one hundred to both sides |
Check yourself. With and uncoded, the coded line is . Find the line of on .
Show the answer
Substituting gives . So the line is , with both the gradient and the intercept changed.
Reference
Results in this chapter
| Result | What it says | When to use it | In the formula booklet? |
|---|---|---|---|
| Spread of x | Every regression | Yes | |
| How x and y vary together | Every regression | Yes | |
| , | The least squares line of y on x | Fitting the line | Yes |
| Residual | Checking the fit | No, learn it | |
| Residual sum of squares | Measuring the fit | Yes | |
| Decode by substitution | Coded lines | Coded data | No, learn it |
Reasoning
Proof workshop: deriving the least squares line
The claim
The values of and that minimise are and .
Strategy
Treat the sum of squares as a function of the two unknowns and . First fix and minimise over , which gives the intercept in terms of . Then substitute back to obtain a quadratic in alone, and minimise that by completing the square or differentiating.
The key insight is that the best intercept for any gradient puts the line through the mean point. After that, only the gradient remains to be chosen.
The proof
For fixed , differentiate with respect to and set the result to zero:
Substituting this intercept, each residual becomes , so the sum of squares is
Since , this is smallest when the squared bracket is zero, that is when .
Checking every step
The first derivative treats as a constant, and dividing by gives . Expanding the square of and summing gives the three summary statistics. Completing the square is checked by expanding it again.
The completed square also shows the minimum value, , which is the residual sum of squares formula from section 5. So the workshop proves two results at once.
A numerical check uses the drinks data: and give , matching worked example 3. Any other gradient adds the positive term to the RSS, as the parabola in section 5 shows.
Your turn
Use the completed square to find the RSS for the drinks data if the gradient 2 is used with a line through the mean point.
Show a model proof
The extra term is . So the RSS is , slightly more than the least squares value, as the proof predicts.
Practice
Practice ladder
Rung 1: Recall and fluency
Q1. For eight pairs, and . Calculate .
Worked solution to Q1
Subtract the square of the total divided by the number of pairs: . This is positive, as every must be.
Q2. For the same pairs, and . Find .
Worked solution to Q2
Subtract the product of the totals divided by the number of pairs: . The positive value shows that tends to rise with .
Q3. Write down the regression line of on for Q1 and Q2.
Worked solution to Q3
The gradient is , and the means are 6 and 25. So the intercept is , and the line is .
Rung 2: Application
Q4. Use the line from Q3 to predict when .
Worked solution to Q4
Substitute the value into the line: . This is a reliable prediction if 5 lies within the range of the observed -values.
Q5. A point is in the data for Q3. Determine its residual and say what it shows.
Worked solution to Q5
The residual is the observed value minus the predicted value, . It is positive, so the point lies above the regression line.
Q6. The drinks line is . Interpret the gradient in context.
Worked solution to Q6
The gradient means that each extra degree of temperature goes with about 1.94 more drinks sold on average. It describes the trend in the data, not a guaranteed increase on any particular day.
Rung 3: Analysis
Q7. For data with , and , compute the residual sum of squares.
Worked solution to Q7
Substitute into the formula: . This is small compared with , so the line explains most of the variation in .
Q8. With and , a coded line is . Deduce the line of on .
Worked solution to Q8
Substitute both codings into the coded line and then rearrange to make the subject: , so . This gives , where both the gradient and the intercept have changed.
Q9. A residual plot shows residuals that are positive at both ends and negative in the middle. Explain what this suggests.
Worked solution to Q9
A curved pattern in the residuals means the points bend away from the straight line in a systematic way. This suggests that a straight line is not a suitable model, and a curve would fit better.
Rung 4: Stretch
Q10. For the drinks data, verify that the residuals in Figure 46.2 add to zero, using the fact that the line passes through the mean point.
Worked solution to Q10
The sum of the residuals is . Since the line passes through the mean point, , so the bracket is zero and the residuals add to zero.
Q11. Show that subtracting a constant from every -value does not change the gradient of the regression line.
Worked solution to Q11
Subtracting a constant moves every value and the mean by the same amount, so the deviations from the mean are unchanged. Therefore and are unchanged, and so is the gradient .
Q12. For the five points in worked example 8, the line is . Deduce the RSS if the gradient 2 is used instead, with a line through the mean point.
Worked solution to Q12
The proof workshop shows the extra term is . So the RSS rises from 1.6 to 2.0, confirming that the least squares gradient is best.
Exam practice
Exam technique and worked answer workshop
How these questions are marked
M1 marks go to correct use of the formulas for , , , , residuals and RSS. A1 marks go to correct values, usually to three significant figures. B1 marks go to interpretation in context, comments on reliability and descriptions of residual plots.
Keep full calculator accuracy until the end. Write the line with defined variables, and comment on interpolation or extrapolation whenever a prediction is made.
Exam question 1 (7 marks · Paper 4 · about 10 minutes)
On eight days, the temperature °C and drinks sold gave , , and . Find the regression line of on , interpret its gradient, and predict sales at 19 °C, commenting on reliability. (7)
Mark scheme for exam question 1
B1
B1
M1
A1
Each degree adds about 1.94 drinks on average B1
Predicts 31.75 M1
Reliable, since 19 °C is within the data range A1
Exam question 2 (5 marks · Paper 4 · about 7 minutes)
For ten pairs, , , , and . Find the regression line of on and the residual sum of squares. (5)
Mark scheme for exam question 2
and B1
M1
A1
with M1
A1
Exam question 3 (6 marks · Paper 4 · about 8 minutes)
Prove that the least squares regression line of on passes through , and show that its residuals add to zero. (6)
Mark scheme for exam question 3
Minimises over M1
A1
So A1
Substituting gives B1
M1
A1
Exam question 4 (6 marks · Paper 4 · about 8 minutes)
The five points , , , and have regression line . Find all the residuals and the residual sum of squares, and identify the point furthest from the line. (6)
Mark scheme for exam question 4
Finds predicted values M1
Residuals 0.4, 0.2, −1.0, −0.2, 0.6 A1
Squares and adds the residuals M1
A1
is furthest from the line B1
It lies below the line, since its residual is negative B1
Exam question 5 (6 marks · Paper 4 · about 8 minutes)
The -values 105, 115, 125, 135, 145 and 155 are coded by , and the regression line of on is . Find the regression line of on , and estimate when . (6)
Mark scheme for exam question 5
Substitutes M1
Gradient A1
Recalculates the intercept M1
A1
Substitutes M1
A1
Exam question 6 (6 marks · Paper 4 · about 8 minutes)
With and , the regression line of on is . Find the regression line of on , and explain why both coefficients change. (6)
Mark scheme for exam question 6
Substitutes both codings M1
A1
Rearranges for M1
A1
Scaling changes the gradient B1
Shifting the origin changes the intercept B1
Exam question 7 (6 marks · Paper 4 · about 8 minutes)
The drinks line was fitted to temperatures from 12 °C to 26 °C. Predict sales at 40 °C, interpret the intercept, and explain why neither value should be trusted. (6)
Mark scheme for exam question 7
Substitutes M1
drinks A1
40 °C is outside the data range B1
So the prediction is extrapolation B1
The intercept, about , is predicted sales at 0 °C B1
Negative sales are impossible, so the line fails there B1
Exam question 8 (6 marks · Paper 4 · about 8 minutes)
Show that when , and hence show that the minimum is . (6)
Mark scheme for exam question 8
Writes the residual as M1
Expands and sums M1
A1
Completes the square or differentiates M1
Minimum at A1
Minimum value A1
Annotated model answer: exam question 1
First, B1 and . B1. The gradient is . M1. With and , the intercept is . A1.
The gradient means that each extra degree goes with about 1.94 more drinks sold on average. B1. At 19 °C the line predicts drinks. M1. This is reliable because 19 °C lies within the range of temperatures observed. A1.
Annotated model answer: exam question 5
Substituting the coding gives . M1. The gradient is . A1. Expanding, , so the intercept must be recalculated. M1. The line is . A1.
At , . M1. This gives . A1.
Connections
Synoptic link
Discrete random variables used sums and means in the same way as the summary statistics here. Correlation measures the strength of the linear relationship whose best line is found in this chapter.
The t-distribution and Estimation, confidence intervals and normal tests develop the inference that can be built on regression. Combinations of normal random variables explains how sums of measurements behave, which underlies residual analysis.
Synoptic question 1. The product moment correlation coefficient is . Explain why and the gradient always have the same sign.
Answer to synoptic question 1
Both and have in the numerator, and their denominators, and , are positive. So both take the sign of . For the drinks data the gradient is 1.94, so is positive too.
Recap
Recap and next step
- , and measure spread and joint variation about the means.
- The least squares line of on has and , and passes through the mean point.
- Interpolation is reliable; extrapolation is not.
- Residuals are observed minus predicted, and they add to zero for the least squares line.
- measures the closeness of fit.
- Decode a coded line by substituting the coding and rearranging.
Next chapter: Continuous random variables, which describes quantities that can take any value in a range, using probability density functions.
For your exam board
This chapter covers Pearson Edexcel A Level Further Mathematics (9FM0) Further Statistics 2 section 1: least squares linear regression, the regression line of y on x, residuals and the residual sum of squares, coded data, and interpolation and extrapolation. It is assessed on Paper 4B, Further Statistics 2. Similar content appears in AQA (7367) and OCR (H245) statistics options.