JC2 · H2 Mathematics · Notes
Choose and fit regression models, use the mean point and residuals, transform variables, assess predictions and apply a fitted model.
Correlation and Regression summary and formula sheet: every method on 3 pages
Mr Ian Ang’s summary of the whole correlation and regression chapter on three pages.
Page 1 of 3 Scatter diagrams, regression lines and choosing a model
H2 Math summary notes
Correlation and Regression formulas and methods, section by section
Page 1 of 3Scatter diagrams, regression lines and choosing a model
Scatter diagram and r: what the shape and the value of r tell you
- The four shapes are positive linear (), negative linear (), curved (non-linear) and no clear relation ().
- . If , all the points lie on a straight line; means strong linear correlation; means no linear correlation (the worst).
- measures how close the points lie to a straight line. is the same in cm or in m, and for either variable.
- Warning for a scatter diagram: label both axes with units, state the lowest and highest value of each, keep the points in the right places, and circle and label an odd point .
The two regression lines: residuals, y on x and x on y
- The residual is observed predicted .
- on is the line with the least , where is measured vertically, and it is .
- on is the line with the least , where is measured horizontally, and it is .
- Squares remove negatives, and a smaller sum is a better fit.
The GC: LinReg and r, with the line of y on x and the product moment correlation coefficient
- (hours studied) is and (score) is . Find the regression line of on and .
- On the GC: STAT, 1: Edit with L1 and L2 . Then STAT, CALC, 4: LinReg(ax+b) with XList: L1, YList: L2, and Calculate.
- Read , and : gives , and Product moment correlation coefficient .
- For on , swap the lists: XList: L2, YList: L1. " on " means YList on XList.
- Warning: write the whole phrase "Product moment correlation coefficient =", not just .
Which regression line? Dependency known, or the variable you are asked to find is the subject
- If the dependency is known, the dependent variable is on the independent one ( on has subject ; on has subject ).
- If there is no clear dependency, the variable you are asked to find is the subject, so use that variable on the other.
- Using the data of section 3, estimate when . The score is given and hours are wanted, so is the subject: on is .
- When , . The two lines coincide only when .
A change of variable: y = Ae^(Bx), turned into a linear law with ln y
- and . Fit and find for and , and and .
- The linear law is . Take : , because .
- GC: (1) L3 . (2) LinReg(ax+b) with XList L1 and YList L3, giving .
- Product moment correlation coefficient between and .
- (the gradient) and , so .
Choosing the model: the |r| closest to 1, and the scatter diagram too
| model | ||
|---|---|---|
- and . Which model fits: , , or ?
- Find for each model on the GC. The values are , , and , so is , , and .
- closest to 1 is , and its line is .
- The scatter diagram agrees: rising, flattening.
- Warning: comparing the values alone is not accepted. Refer to the scatter diagram too.
Page 2 of 3Estimates, shapes, interpretation and summary data
Estimates: interpolation and extrapolation with y = 3.125 + 4.232 ln x
- Use from section 6, with the data range .
- : . This is interpolation: is within the data range and is close to 1, so the estimate is reliable.
- : . This is extrapolation: is outside the data range , so the relation may not hold and the estimate is not reliable.
Describing the shape: linear or not, concave up or down, increasing or decreasing, and the rate
- Say: linear or not; concave up or down; increasing or decreasing, at an increasing or decreasing rate.
- The four curves are with , with , with , and with .
- : increasing at a decreasing rate. : decreasing at a decreasing rate.
- , : increases at an increasing rate.
Interpreting b and r, and the long run, for y = 30.99 + 5.427x
- Using from section 3.
- Gradient: the score rises by approximately for every extra hour studied.
- : hours studied and score are strongly positively linearly correlated.
- Long run: the line gives a score above from hours on, which cannot happen, so the model is not suitable for large .
- Warning: correlation does not imply causation. A strong does not show that one variable causes the other.
Finding an unknown value: (x bar, y bar) lies on both regression lines
- and . The line of on is . Find .
- lies on both regression lines. GC: .
- , so .
- , so .
- A new point keeps unchanged if it is , here .
Sum of squares of the residuals: S, and the regression line gives the minimum
- and . Find for the line .
- GC: (1) L3 and L4 . (2) STAT CALC 1-Var Stats, List L4: read .
- .
- The regression line gives , the minimum.
When the data change: adding to every y, standard deviation and r, and a change of units
- Add to every : increases by .
- The standard deviation and do not change. also does not change for a change of units.
- with in minutes. Rewrite for , in hours: .
- So .
From summary data: the line of x on y and r from sums
- , , , , and . Find the line of on and .
- and .
- .
- , so .
- .
Page 3 of 3Pictures: residuals, the two lines, estimates and the sum of squares
The regression line and the residuals, through the mean point
- The picture shows the six points of section 3 with the line , which passes through .
- The purple segments are the residuals: observed predicted , drawn vertically from each point to the line.
- The line makes the sum of as small as possible.
- The vertical axis starts at , so the picture does not begin at zero.
Interpolation and extrapolation drawn on y = 3.125 + 4.232 ln x
- The curve is with data for .
- The blue band is the data range. lies inside it and gives (interpolation), which is reliable.
- The dashed part is outside the data range. gives (extrapolation), and the relation may not hold there.
A change of variable makes it a line: y = Ae^(Bx) and ln y = ln A + Bx
- For , the graph of against is a curve that rises faster and faster.
- The graph of against is a straight line, because .
- From section 5, and .
The two lines cross at the mean point: a looser scatter of six points
- The scatter is looser than in section 14, with six points of our own, so that the two lines can be seen apart.
- on uses the vertical distance ; on uses the horizontal distance .
- Both lines pass through .
- They are the same line only when .
Sum of squares of the residuals: S drawn for Y = 1.0 + 1.8x
- The five points of section 11 are drawn with the line .
- The residuals are , , , and .
- Squaring them gives .
- The regression line would give the minimum, .
Choosing the model, on the scatter: a + b ln x against a + bx
- The six points have and to .
- The points rise then flatten, and the curve fits them.
- The straight line (dashed) misses the ends.
Worked examples
Correlation and Regression worked examples
Mr Ian’s worked examples for the chapter, with the full working.
Read the scatter diagram before trusting r
The product moment correlation coefficient r measures linear association between the two variables entered. A curved relationship may still have a large . Label axes with variables and units, look for curvature and unusual points, then choose the response variable and any transformation. An association in observational data does not establish cause and effect.
A regression line passes through the mean point
Find a missing assessment score
Five students have practice scores and assessment scores . The regression line of y on x is . Find k.
The mean point lies on the regression line:
The line is a model for the whole dataset. It need not pass through the observed point ; substituting x = 3 and claiming k = 5 would be wrong.
Fit the response on the predictor
Estimate in each direction
Use the completed data . Find both regression lines. Estimate y when x = 4, then estimate x when y = 6, treating neither score as a controlled independent variable.
The centred sums are:
For y on x, minimise vertical y residuals:
For x on y, minimise residuals in the x direction instead:
For the observed point (3, 3), the y-on-x line predicts y = 5 at x = 3. Its vertical residual is . The x-on-y line predicts x = 2 at y = 3. Its horizontal residual is . Measure each residual parallel to the response axis; the two fits minimise different sums of squares.
Rearranging the y-on-x line would give , a different estimate. Choose the regression direction from the prediction required when neither variable is clearly controlled. If the experiment identifies a controlled predictor, keep the fitted response-on-predictor model and interpret any reverse use within that model.
Both regression slopes are positive, agreeing with the sign of r. Their product is , not 1.
Residuals explain what least squares minimises
Calculate the minimum sum of squared residuals
For the same five score pairs, calculate the residuals from . Let for any line y = a + bx. Find a lower bound for S.
| x | Observed y | Predicted y | Residual |
|---|---|---|---|
| 1 | 2 | 2.4 | −0.4 |
| 2 | 5 | 3.7 | 1.3 |
| 3 | 3 | 5.0 | −2.0 |
| 4 | 8 | 6.3 | 1.7 |
| 5 | 7 | 7.6 | −0.6 |
Therefore , with equality for the least-squares line. It minimises the sum of squared vertical residuals. It does not make each residual zero.
Every line through has residual sum zero, because . Only one of those lines minimises the sum of squared residuals:
Change the slope while retaining the mean point
b = 1.3, a = 1.1: sum of residuals 0.00; sum of squared residuals 9.10. This is the least-squares fit.
A curved relationship needs the right transformed predictor
Growth that slows down
A plant’s heights h cm at ages t weeks are shown below. Compare with , then estimate its height at six weeks.
| t (weeks) | 1 | 2 | 4 | 8 | 16 |
|---|---|---|---|---|---|
| h (cm) | 3.0 | 6.6 | 9.8 | 13.5 | 16.7 |
Height increases at a decreasing rate. A straight line in t would impose a constant increase; a positive term would impose an increasing rate. Both proposed transformed models have the observed slowing shape, so compare their transformed correlations.
| Variables entered | r |
|---|---|
| 0.978472 | |
| 0.999749 |
The log model fits these data better. Put , regress h on u, then restore t:
For six weeks,
Six weeks lies in the data range 1–16 weeks and the correlation between h and is very strong. These support interpolation, assuming the same growth conditions. In the long run the model is unsuitable for a plant with a limiting height: grows without bound, although increasingly slowly.
The relevant r is between h and , not between h and t. A near-perfect transformed correlation does not prove that the model remains valid outside the observed ages.
Changing units in a transformed model
Rewrite the fitted plant model using age v in days, where v = 7t. Explain the effect on its correlation coefficient.
The transformed predictor differs only by a constant, so the correlation between h and the transformed predictor is unchanged. The intercept changes; the slope in front of the logarithm stays the same.
For ordinary variables, positive rescaling or adding a constant leaves r unchanged. Multiplying one variable by a negative constant reverses its sign. Replacing a variable with its square, reciprocal or logarithm can change r because that is not generally a linear change of the original variable.
Use the fitted model for a further calculation
Predict renovation time, then minimise estimated wages
The observed working days y for crews of x workers are shown below. A model , with a, b positive, is proposed. Fit it and find the crew size from 4 to 16 workers that minimises total wages at $120 per worker per day.
| Workers x | 4 | 6 | 8 | 10 | 12 | 16 |
|---|---|---|---|---|---|---|
| Working days y | 58 | 31 | 22 | 19 | 16 | 14 |
As the crew grows, completion time decreases more slowly toward a positive lower limit. A reciprocal-square model allows that limit; a decreasing logarithmic model would eventually predict negative working days. Regress y on :
The transformed correlation is . It is positive because y rises with , even though y decreases with x. For nine workers, the fitted time is about 20.1 days; this is interpolation within 4–16 workers.
Total estimated wages depend on both the crew size and duration:
The derivative is negative below this value and positive above it. Crew size is an integer, so compare the neighbouring integers:
| Workers | 8 | 9 |
|---|---|---|
| Estimated wages | $21640.10 | $21689.22 |
Hire eight workers under this fitted cost model. The estimate assumes all workers are paid for the modelled duration and ignores scheduling or productivity changes not represented in these data. Choosing the smallest predicted duration alone would not minimise wages.
An exponential model transforms the response
A decaying signal has measured strengths 101, 79, 65 and 51 units at times t = 0, 1, 2 and 3 s. Fit using linear regression on the logarithms, then predict its strength at 4 s.
Since all strengths are positive, take logarithms of the response:
Regress on t. The fitted line is
This predicts outside the observed range 0–3 s, so it is extrapolation and depends on the decay law continuing. The log fit minimises squared residuals in , not squared residuals in y. Do not compare those two sums as if they used the same response scale.
Before you finish
State exactly which transformed variables produced r. Pair each prediction with its data range and fit quality. Inspect unusual points before omitting them: an outlier is not automatically an error. Distinguish interpolation from extrapolation, and association from a causal conclusion. Preserve unrounded coefficients for predictions and squared-residual calculations.