For study hours x = 2, 4, 5, 6, 8 and marks y = 50, 60, 55, 70, 80, find both regression lines, verify r from the coefficients, predict the marks for 7 hours and the hours for 75 marks, and find the standard error of estimate.
Regression fits a line or curve that predicts one variable from another. Least squares gives two regression lines through (x̄, ȳ) whose slopes byx and bxy multiply to r²; logarithms straighten exponential and power curves, and extra normal equations fit parabolas.
Regression estimates the value of a dependent variable (the response y) from an independent variable (the predictor or regressor x). Simple linear regression uses one predictor and a straight line y = a + bx. The name comes from Francis Galton's study of heights (1886): children of very tall parents were, on average, shorter than their parents — heights “regressed towards mediocrity”, that is, towards the mean.
For a candidate line y = a + bx, the residual of a point is eᵢ = yᵢ − (a + bxᵢ), its vertical distance from the line. Least squares chooses a and b to make S = Σeᵢ² as small as possible. Squaring stops positive and negative errors cancelling, punishes large errors more, and gives a clean closed-form answer. Adrien-Marie Legendre published the method in 1805; Carl Friedrich Gauss had used it earlier, famously to recover the orbit of the asteroid Ceres in 1801.
Dividing normal equation 1 by n gives ȳ = a + b·x̄: the least-squares line always passes through the point of means. The residuals always add to zero, and the line is unique as long as the x-values are not all equal. For the line of x on y, x = a′ + b′y, the roles simply swap: Σx = na′ + b′Σy and Σxy = a′Σy + b′Σy².
Two quick consequences tie regression to correlation. Substituting a = ȳ − b·x̄ into normal equation 2 gives Σxy − n·x̄·ȳ = b(Σx² − n·x̄²), i.e. b = Σdxdy/Σdx² = cov/σx² = r·σy/σx. The same algebra for x on y gives b′ = r·σx/σy, so the product of the two slopes is r² — the basis of r = ±√(byx·bxy).
Why two lines? The line of y on x minimises the squared vertical deviations, while the line of x on y minimises the squared horizontal deviations. Different criteria give different lines unless the points lie exactly on one line. Using the y-on-x line to predict x is a classic mistake.
A classic question gives two regression equations without saying which is which. First solve them together to get (x̄, ȳ). Then try one assignment: rewrite the supposed y-on-x line as y = … to read byx, and the other as x = … to read bxy. If byx·bxy ≤ 1 (and the signs agree) the assignment is right; if the product exceeds 1, swap the roles. Finally r = ±√(byx·bxy).
Because regression coefficients ignore a change of origin, the assumed-mean table built in the correlation topic (advertising x and sales y, with u = x − 46 and v = y − 120) gives both lines directly: n = 6, Σu = 6, Σv = 0, Σu² = 76, Σv² = 336, Σuv = 148.
A change of scale does matter, and it is easy to undo. Code the advertising as u′ = (x − 46)/2 (so h = 2) and keep v: then Σu′ = 3, Σu′² = 19, Σu′v = 74, and b_vu′ = [6(74) − 3(0)]/[6(19) − 3²] = 444/105 ≈ 4.229. Converting back, byx = (k/h)·b_vu′ = (1/2)(4.229) ≈ 2.114 — the same line as before.
The typical size of a prediction error is measured by the standard error of estimate: Syx = σy·√(1 − r²) for the line of y on x (and Sxy = σx·√(1 − r²) for x on y). When r = ±1 it is 0 — every prediction is exact; when r = 0 it equals σy — knowing x does not help at all.
A fitted line is trustworthy only inside the range of the observed x-values. Extending it far outside — extrapolation — assumes the straight-line pattern continues, which it often does not (a plant's height does not keep growing linearly for ever).
Many relationships are curved: compound growth is exponential, physical laws are often power laws, and costs can be quadratic. There are two standard approaches: transform the variables (usually with logarithms) so that the curve becomes a straight line, or fit a polynomial directly with more normal equations.
| Model | Transformation | Straight-line form Y = A + BX | Back-transform |
|---|---|---|---|
| y = a·bˣ (exponential) | Y = log y, X = x | log y = log a + x·log b | a = 10^A, b = 10^B |
| y = a·e^(bx) | Y = ln y, X = x | ln y = ln a + b·x | a = e^A, b = B |
| y = a·xᵇ (power) | Y = log y, X = log x | log y = log a + b·log x | a = 10^A, b = B |
| y = a + b/x | Y = y, X = 1/x | y = a + b·X | a = A, b = B |
| y = a + bx + cx² (parabola) | none — fit directly | three normal equations (below) | — |
Which curve? Plot first. If log y against x looks straight, try y = abˣ (or y = ae^(bx)); if log y against log x looks straight, try y = axᵇ; if, for equally spaced x, the second differences of y are roughly constant, try a parabola. Exponential models describe growth and decay — population, bacterial counts, compound interest (b > 1, or b > 0 in the e-form) and radioactive decay or depreciation (b < 1, or b < 0).
The y-on-x line can be written in standard units: (ŷ − ȳ)/σy = r·(x − x̄)/σx. Since |r| < 1, a prediction always lies fewer standard deviations from its mean than x does. That is regression to the mean: the toppers of a mock test tend, on average, to score a little lower in the final, and the weakest a little higher — a purely statistical effect, not proof that coaching harmed the toppers or helped the others.
Try the problem first, then reveal the working one step at a time.
For study hours x = 2, 4, 5, 6, 8 and marks y = 50, 60, 55, 70, 80, find both regression lines, verify r from the coefficients, predict the marks for 7 hours and the hours for 75 marks, and find the standard error of estimate.
The regression lines of a bivariate distribution are 4x + 5y = 74 and 5x + y = 40. Find x̄ and ȳ, identify the lines, find r, and find σy if σx = 4.
Fit y = a + bx + cx² to x = 0, 1, 2, 3, 4 and y = 2.1, 2.9, 6.2, 10.8, 18.1.
Fit y = a·bˣ to x = 0, 1, 2, 3, 4 and y = 3, 6.1, 11.8, 24.5, 47.9.
Given x̄ = 20, ȳ = 30, σx = 4, σy = 6 and r = 0.75, find both regression lines and estimate y when x = 24.
(a) If byx = 0.4 and bxy = 1.6, find r. (b) Can byx = 2.5 and bxy = 0.5 be the regression coefficients of the same data?
The two regression lines are x + 2y = 5 and 2x + 3y = 8. Find the means and the correlation coefficient.
Fit a curve y = a·xᵇ to x = 1, 2, 3, 4 and y = 2, 5.7, 10.4, 16.
If σx = σy and r = 0.5, find the acute angle between the two regression lines.
12 questions. 70 % passes the topic quiz (+30 XP, +20 more for 100 %). Exam scoring: +1 correct, −⅓ wrong.
Modelled on real KPSC questions (reworded) with the same concept and answer; each links to its original paper.