CalcPath
ProgressProblem setsFeedback
← Question sheet

Statistics · Solutions

Correlation and Regression

12 questions · about 101 minutes

Work this sheet on paper, showing every step — the method is what is being checked, and the solutions are written so you can follow your own route rather than just compare a final number. Name every result you use (“by Gauss–Markov”, “by the decomposition of variation”, “from the normal equations”) and say which of the LINE conditions each inferential step relies on. The arithmetic has been chosen so that no calculator is needed: leave surds as surds and use only the approximations supplied in the questions. Full worked solutions are on a separate page; each question also has its own reveal, so you can check one answer without seeing the rest.

  1. 1.Computation

    Four paired observations are recorded: (2,1), (4,2), (6,4), (8,5).

    1. (a)Compute Sxx​, Syy​, Sxy​ and the sample correlation r exactly, leaving any surd as a surd. Check your value against the theorem that bounds r.
    2. (b)The x values are re-expressed as x′=3x+1 and the y values as y′=4−y. Without recomputing any sum, state the new correlation r′ and justify it by naming the result you are using. Then confirm it by computing Sx′y′​, Sx′x′​ and Sy′y′​ from the originals.
    3. (c)Now take the five points x=−2,−1,0,1,2 with y=x2. Compute r, and say precisely what this example shows about what the correlation does and does not measure.

    Solution

    (a) Centre, then sum. xˉ=20/4=5 and yˉ​=12/4=3. The deviations are u=−3,−1,1,3 and v=−2,−1,1,2, so

    Sxx​=9+1+1+9=20,Syy​=4+1+1+4=10,Sxy​=6+1+1+6=14.

    Hence

    r=Sxx​Syy​​Sxy​​=200​14​=102​14​=1072​​≈0.99.

    Sanity check: r2=98/100<1, as the theorem Correlation lies between −1 and 1 requires, and it is strictly less than 1 because the points are not collinear — the slope from (2,1) to (4,2) is 21​, while from (4,2) to (6,4) it is 1.

    (b) Invoke invariance; recompute nothing. By the proposition Correlation is invariant under increasing linear rescaling, if x′=a+bx and y′=c+dy then r′=sign(bd)r. Here b=3 and d=−1, so bd<0 and

    r′=−1072​​.

    The shifts +1 and 4 do nothing, because centring removes them; the factor 3 scales Sxy​ and Sxx​​ equally and cancels; only the sign of d survives.

    Confirmation: centring gives xi′​−xˉ′=3(xi​−xˉ) and yi′​−yˉ​′=−(yi​−yˉ​), so Sx′y′​=3⋅(−1)⋅14=−42, Sx′x′​=9×20=180 and Sy′y′​=1×10=10. Then

    r′=1800​−42​=302​−42​=−52​7​=−1072​​. ✓

    (c) A perfect relationship with zero correlation. xˉ=0 and yˉ​=(4+1+0+1+4)/5=2. The y-deviations are v=2,−1,−2,−1,2, and since xˉ=0 the x-deviations are the x values themselves:

    Sxy​=(−2)(2)+(−1)(−1)+(0)(−2)+(1)(−1)+(2)(2)=−4+1+0−1+4=0.

    So r=0 exactly, even though y is determined by x without any noise at all. (For the record Sxx​=10 and Syy​=4+1+4+1+4=14, both positive, so r is well defined.)

    The lesson: r measures linear association only. Every product ui​vi​ on the left of 0 is cancelled by its mirror image on the right, because the parabola rises on one side exactly as it falls on the other. A correlation of zero is compatible with a deterministic relationship, which is why a correlation quoted without a scatterplot has not had its meaning checked.

  2. 2.Computation

    For the four points (2,1), (4,2), (6,4), (8,5) you may take xˉ=5, yˉ​=3, Sxx​=20, Syy​=10, Sxy​=14 and r=72​/10 as given.

    1. (a)Find the least-squares line y^​=b0​+b1​x, naming the theorem that supplies the formulas, and check that the line passes through the point of means.
    2. (b)Compute the four fitted values and the four residuals, and verify both identities ∑i​ei​=0 and ∑i​xi​ei​=0 numerically.
    3. (c)Verify the relation b1​=rsy​/sx​ for this data, and use it to explain what is meant by “regression to the mean” for a point one standard deviation above xˉ.

    Solution

    (a) The least-squares estimates. By the theorem The least-squares estimates, the minimiser of ∑i​(yi​−b0​−b1​xi​)2 is

    b1​=Sxx​Sxy​​=2014​=107​,b0​=yˉ​−b1​xˉ=3−107​⋅5=3−27​=−21​.

    The line is y^​=−0.5+0.7x. At x=xˉ=5 it gives −0.5+3.5=3=yˉ​, so it passes through (xˉ,yˉ​) — which is exactly what the first normal equation says.

    (b) Fitted values and residuals.

    y^​=0.9, 2.3, 3.7, 5.1at x=2,4,6,8,

    so the residuals ei​=yi​−y^​i​ are

    e=1−0.9, 2−2.3, 4−3.7, 5−5.1=0.1, −0.3, 0.3, −0.1.

    Sum: 0.1−0.3+0.3−0.1=0. ✓ Weighted sum: 2(0.1)+4(−0.3)+6(0.3)+8(−0.1)=0.2−1.2+1.8−0.8=0. ✓ Both hold by the proposition Two properties of least-squares residuals — they are the two normal equations rewritten, so they hold for every data set, not just this one.

    (c) Slope equals correlation in standard units. sy​/sx​=Syy​/Sxx​​, since both standard deviations carry the same divisor n−1, which cancels. So

    rsx​sy​​=1072​​⋅2010​​=1072​​⋅2​1​=107​=b1​. ✓

    This is the corollary Slope, correlation and the regression effect. Read it in standard units: a point at xˉ+sx​ is predicted at yˉ​+rsy​, that is r≈0.99 standard deviations above yˉ​ — closer to its mean, in relative terms, than the predictor was to its own. With r this close to 1 the pull is slight; with r=0.5 the prediction would sit only half a standard deviation up. Nothing is acting on anything: regression to the mean is what imperfect correlation looks like when you predict.

  3. 3.Proof

    Let b0​,b1​ be the least-squares estimates for data (xi​,yi​), i=1,…,n, with Sxx​>0, and let y^​i​=b0​+b1​xi​ and ei​=yi​−y^​i​. Work only from the fact that (b0​,b1​) minimises Q(b0​,b1​)=∑i​(yi​−b0​−b1​xi​)2.

    1. (a)Prove that ∑i​ei​=0 and ∑i​xi​ei​=0.
    2. (b)Deduce that ∑i​y^​i​ei​=0.
    3. (c)Deduce that the sample correlation between the xi​ and the ei​ is exactly zero whenever the residuals are not all zero, and explain what this means for a plot of residuals against x.

    Solution

    (a) The normal equations. Q is a differentiable function of (b0​,b1​) and the minimum is attained (it is a positive-definite quadratic when Sxx​>0, as the theorem The least-squares estimates shows), so both partial derivatives vanish there:

    ∂b0​∂Q​=−2i∑​(yi​−b0​−b1​xi​)=−2i∑​ei​=0,

    ∂b1​∂Q​=−2i∑​xi​(yi​−b0​−b1​xi​)=−2i∑​xi​ei​=0.

    Dividing by −2 gives ∑i​ei​=0 and ∑i​xi​ei​=0. ■

    (b) Fitted values are a combination of 1 and x. Since y^​i​=b0​+b1​xi​,

    i∑​y^​i​ei​=b0​i∑​ei​+b1​i∑​xi​ei​=b0​⋅0+b1​⋅0=0. ■

    Geometrically: the residual vector is orthogonal to the column of ones and to the column of x's, hence to everything in their span, and the fitted vector lies in that span.

    (c) Residuals are uncorrelated with the predictor. By (a) the mean residual is eˉ=n1​∑i​ei​=0. Therefore

    Sxe​=i∑​(xi​−xˉ)(ei​−eˉ)=i∑​(xi​−xˉ)ei​=i∑​xi​ei​−xˉi∑​ei​=0−0=0.

    If the residuals are not all zero then See​>0, and Sxx​>0 by hypothesis, so rxe​=Sxe​/Sxx​See​​=0. ■

    Consequence: a plot of e against x can never show a linear trend, whatever the data — a least-squares line through that plot would have slope Sxe​/Sxx​=0. That is a property of how the line was chosen, not evidence about the data. What the plot can show is anything non-linear: curvature, or a spread that changes with x. Those are the two things the fitting procedure did not remove, and they are exactly what the residual plot is used to diagnose.

  4. 4.Computation

    The line y^​=−0.5+0.7x was fitted to (2,1),(4,2),(6,4),(8,5), with residuals 0.1,−0.3,0.3,−0.1, and Sxx​=20, Syy​=10, Sxy​=14, r=72​/10.

    1. (a)Compute SSR from the identity SSR=b1​Sxy​, compute SSE directly from the residuals, and verify the decomposition SST=SSR+SSE. State why the cross term in that decomposition vanishes.
    2. (b)Compute R2 and confirm that it equals r2.
    3. (c)Compute s2 and s exactly, say in one sentence what s measures, and explain why R2=0.98 does not by itself establish that a straight line is the right model.

    Solution

    (a) The three sums of squares. By the proposition For simple regression, R-squared is r squared, SSR=b1​Sxy​=0.7×14=9.8; as a check, b12​Sxx​=0.49×20=9.8 as well. Directly from the residuals,

    SSE=0.01+0.09+0.09+0.01=0.20.

    With SST=Syy​=10 we get SSR+SSE=9.8+0.2=10=SST. ✓

    The cross term 2∑i​(y^​i​−yˉ​)(yi​−y^​i​) vanishes because y^​i​−yˉ​=b1​(xi​−xˉ), so it equals 2b1​(∑i​xi​ei​−xˉ∑i​ei​)=2b1​(0−0)=0 by the proposition Two properties of least-squares residuals — this is the theorem Decomposition of variation in regression.

    (b) Coefficient of determination.

    R2=SSTSSR​=109.8​=0.98,r2=(1072​​)2=10049×2​=0.98. ✓

    The line accounts for 98% of the variation in y.

    (c) Residual standard error. Two parameters were estimated, so the divisor is n−2=2:

    s2=n−2SSE​=20.2​=0.1,s=10​1​=1010​​≈0.32.

    s estimates σ, the standard deviation of an observation about the true line — roughly, how far a typical point sits from the fitted line in the units of y. Against yˉ​=3 that is a small scatter, consistent with the high R2.

    But R2 is computed from three sums of squares and is blind to the pattern of the residuals. Anscombe's quartet has four data sets with identical r, identical fitted line and identical R2, of which one is curved, one is driven by a single high-leverage point and one contains an outlier. Here the residuals 0.1,−0.3,0.3,−0.1 alternate in sign with no trend, which is reassuring — but that reassurance came from looking at the residuals, not from the 0.98.

  5. 5.Sketch

    An experimenter measures a response at x=0,1,2,3,4 and records y=0,1,4,9,16. (The response is in fact y=x2 exactly, but the experimenter does not know this and fits a straight line.)

    1. (a)Fit the least-squares line.
    2. (b)Compute the five fitted values and residuals, then SSE, SST and R2 as an exact fraction.
    3. (c)Sketch the scatterplot with the fitted line drawn on it, and beneath it the plot of residuals against fitted values. Every feature you draw must be labelled with a number from (a) or (b). Name the LINE condition the second plot shows to be violated, and explain why the R2 of (b) failed to reveal it.

    Solution

    (a) Fit the line. xˉ=2 and yˉ​=30/5=6. Deviations: u=−2,−1,0,1,2 and v=−6,−5,−2,3,10. Then

    Sxx​=4+1+0+1+4=10,Sxy​=12+5+0+3+20=40,

    so b1​=40/10=4 and b0​=6−4⋅2=−2. The fitted line is y^​=−2+4x.

    (b) Residuals and the sums of squares. Fitted values at x=0,1,2,3,4 are −2,2,6,10,14, so the residuals are

    e=0−(−2), 1−2, 4−6, 9−10, 16−14=2, −1, −2, −1, 2.

    Check: ∑ei​=0 and ∑xi​ei​=0−1−4−3+8=0. ✓

    SSE=4+1+4+1+4=14,SST=Syy​=36+25+4+9+100=174,

    and SSR=b1​Sxy​=160, with 160+14=174. ✓ Hence

    R2=174160​=8780​≈0.92.

    (c) The two pictures. Scatterplot. Mark the five points (0,0),(1,1),(2,4),(3,9),(4,16); they rise ever more steeply. Draw the line y=−2+4x through (0,−2) and (4,14); it passes through the point of means (2,6). The line lies below the data at both ends — at x=0 the point is 2 above it, at x=4 it is 2 above — and above the data in the middle, by 1,2,1 at x=1,2,3. The line crosses the curve where x2=4x−2, that is at x=2±2​≈0.6 and 3.4; mark those two crossings.

    Residual plot. Horizontal axis: fitted value, from −2 to 14; vertical axis: residual, from −2 to 2, with a dashed line at 0. Plot (−2,2), (2,−1), (6,−2), (10,−1), (14,2). The points trace a clear U: positive at both ends, negative in the middle, symmetric about the centre. This is not a random band about zero.

    Which condition fails. Linearity. E(Y∣x) is x2, not β0​+β1​x, so the line is systematically too low at the ends and too high in the middle, and the residuals inherit that curvature. (Independence, normality and equal variance are not what this plot indicts — there is no noise at all.)

    Why R2 did not see it. R2=1−SSE/SST depends on the residuals only through the single number ∑ei2​=14. Reorder the same five residuals to 2,−2,2,−1,−1 and R2 is unchanged, though the U has vanished. A fit accounting for 92% of the variation sounds excellent, and the line is a decent summary of the trend — but the model is wrong in a way that would ruin every prediction at the ends, and only the residual plot says so. That is the pitfall of Anscombe's quartet made concrete.

  6. 6.Proof

    Assume Yi​=β0​+β1​xi​+εi​ with the errors independent, E(εi​)=0 and Var(εi​)=σ2 for every i. Normality is not assumed. Write wi​=(xi​−xˉ)/Sxx​.

    1. (a)Show that b1​=∑i​wi​Yi​, and prove the three identities ∑i​wi​=0, ∑i​wi​xi​=1 and ∑i​wi2​=1/Sxx​.
    2. (b)Deduce that E(b1​)=β1​ and Var(b1​)=σ2/Sxx​, stating at each step which assumption is being used.
    3. (c)Four observations are to be taken on the interval [2,8]. Design A uses x=2,4,6,8; design B uses x=2,2,8,8. Compute Var(b1​) under each, say which is more precise and by what factor, and explain what design B is incapable of detecting.

    Solution

    (a) The slope is linear in the responses. Since ∑i​(xi​−xˉ)=0, the constant Yˉ drops out of the covariance sum:

    SxY​=i∑​(xi​−xˉ)(Yi​−Yˉ)=i∑​(xi​−xˉ)Yi​−Yˉi∑​(xi​−xˉ)=i∑​(xi​−xˉ)Yi​,

    so b1​=SxY​/Sxx​=∑i​wi​Yi​. For the identities:

    i∑​wi​=Sxx​1​i∑​(xi​−xˉ)=0;

    i∑​wi​xi​=Sxx​1​i∑​(xi​−xˉ)[(xi​−xˉ)+xˉ]=Sxx​1​(Sxx​+xˉ⋅0)=1;

    i∑​wi2​=Sxx2​1​i∑​(xi​−xˉ)2=Sxx2​Sxx​​=Sxx​1​. ■

    (b) Mean and variance. Linearity of the model and E(εi​)=0 give E(Yi​)=β0​+β1​xi​, so by linearity of expectation

    E(b1​)=i∑​wi​(β0​+β1​xi​)=β0​i∑​wi​+β1​i∑​wi​xi​=β0​⋅0+β1​⋅1=β1​.

    For the variance, independence kills every cross term, so the variance of the sum is the sum of the variances: Var(b1​)=∑i​wi2​Var(Yi​). Equal variance makes every Var(Yi​)=σ2, hence

    Var(b1​)=σ2i∑​wi2​=Sxx​σ2​. ■

    Normality was never used — this is the unbiasedness and variance part of the theorem Gauss–Markov, and the corollary Precision of the slope. Normality enters only when the t distribution is needed for intervals.

    (c) Two designs. Under A, xˉ=5 with deviations ±3,±1, so Sxx​=9+1+1+9=20 and Var(b1​)=σ2/20. Under B, xˉ=5 with every deviation ±3, so Sxx​=4×9=36 and Var(b1​)=σ2/36.

    Design B is more precise, by the factor 36/20=9/5=1.8: pushing the x's to the ends of the interval maximises Sxx​, which is the denominator in the variance. This is the remark How to make a slope precise — with a trusted linear model, half the points at each extreme is optimal.

    What B cannot do is check linearity. With only two distinct x values there are only two group means, and a line has two parameters, so the least-squares line passes exactly through both means. Every residual is then a within-group deviation; the residual-versus-fitted plot has two vertical stacks and no capacity to bend. Had the true relationship been curved between 2 and 8, design B would report a perfect straight line and could never know otherwise. Design A gives up some precision to buy the ability to see the U of the previous question.

  7. 7.Computation

    For the four points (2,1),(4,2),(6,4),(8,5): y^​=−0.5+0.7x, n=4, xˉ=5, Sxx​=20, SSR=9.8, SSE=0.2, s2=0.1. Assume the full LINE conditions. You may use t0.025,2​=4.303, 2​≈1.414 and 10​≈3.162.

    1. (a)Compute the standard error of b1​ exactly, and test H0​:β1​=0 against H1​:β1​=0 at α=0.05. State the sampling distribution you are using and its degrees of freedom.
    2. (b)Give a 95% confidence interval for β1​.
    3. (c)At x0​=5 give a 95% confidence interval for the mean response E(Y∣x0​) and a 95% prediction interval for a single new observation. Express both standard errors exactly, identify the term responsible for the difference, and state the exact ratio of the two half-widths.
    4. (d)Compute F=MSR/MSE and verify that it equals t2 from (a).

    Solution

    (a) Standard error and test. By the corollary Precision of the slope,

    SE(b1​)=Sxx​​s​=200.1​​=2001​​=102​1​=202​​≈0.0707.

    By the theorem Sampling distribution of the slope, under H0​ the statistic b1​/SE(b1​) follows tn−2​=t2​. Here

    t=2​/200.7​=2​14​=72​≈9.90.

    Since 9.90>4.303, reject H0​: the predictor carries linear information about the response, even with only two degrees of freedom to spare.

    (b) Interval for the slope. b1​±t0.025,2​SE(b1​)=0.7±4.303×0.0707=0.7±0.304, so the interval is approximately (0.40, 1.00). It excludes 0, in agreement with (a), and it is wide: two degrees of freedom make t0.025,2​ more than twice the familiar 1.96.

    (c) Two intervals at the centre. y^​0​=−0.5+0.7×5=3, and (x0​−xˉ)2=0, so by the theorem Confidence and prediction intervals:

    Mean response. SE=s1/n​=s/2=210​1​=2010​​≈0.158. Margin 4.303×0.158≈0.68; interval (2.32, 3.68).

    New observation. SE=s1+1/n​=s5​/2=210​5​​=22​1​=42​​≈0.354. Margin 4.303×0.354≈1.52; interval (1.48, 4.52).

    The difference is the extra 1 under the root: Var(Y0​−y^​0​)=σ2+Var(y^​0​), the σ2 being the new observation's own noise ε0​, independent of everything used to fit. The ratio of half-widths is

    1/4​1+1/4​​=5​≈2.24,

    and it would be even larger for bigger n, since the numerator has a floor at 1 while the denominator tends to 0.

    (d) The F check. MSR=SSR/1=9.8 and MSE=SSE/(n−2)=0.2/2=0.1, so F=9.8/0.1=98. From (a), t2=(72​)2=49×2=98. ✓ The two tests are the same test: the model comparison between the fitted line and the intercept-only model, with F1,ν​=tν2​.

  8. 8.Critique

    A student fits y^​=−0.5+0.7x to the four points (2,1),(4,2),(6,4),(8,5), obtaining R2=0.98, s=1/10​≈0.316, Sxx​=20, xˉ=5, and writes the following report.

    Step 1. Since R2=0.98, the line explains 98% of the variation, so the relationship is certainly real and no test of the slope is required.

    Step 2. A 95% interval for the value of y that will be observed next time x=5 is 3±4.303×0.316×1/4​=3±0.68.

    Step 3. The interval in Step 2 shrinks to zero width as n→∞, so with enough data the next observation at x=5 could be predicted exactly.

    Step 4. Because the fitted line passes through (xˉ,yˉ​), the interval in Step 2 has the same width at every x0​.

    You may use t0.025,2​=4.303, 2​≈1.414, 7​≈2.646 and 10​≈3.162.

    1. (a)Identify every flaw. For each, say which theorem, term or distinction is being misused. (One step is correct; say which.)
    2. (b)Give the correct 95% interval for the next observation at x0​=5, and the correct 95% interval for the mean response at x0​=8.

    Solution

    (a) Four steps, three flaws.

    Step 1 confuses R2 with a test. R2 is a descriptive ratio of sums of squares; it has no sampling distribution attached and says nothing about whether β1​=0 is compatible with the data. The theorem Sampling distribution of the slope is what settles that, and it needs n: on tiny data a large R2 can coexist with an insignificant slope. As it happens the test here gives t=72​≈9.9 against 4.303 and the slope is significant — but that conclusion comes from the test, not from the 0.98. The number is right; the reasoning is not.

    Step 2 uses the wrong interval. The formula s1/n+(x0​−xˉ)2/Sxx​​ is the standard error of y^​0​ as an estimate of the mean response E(Y∣x0​). A single new observation has its own error ε0​, and by the theorem Confidence and prediction intervals the variance of Y0​−y^​0​ is σ2(1+1/n+(x0​−xˉ)2/Sxx​) — the 1 is missing. The interval quoted is a confidence interval for the mean masquerading as a prediction interval, and it is far too narrow.

    Step 3 is wrong for the interval it claims to be about. The mean-response interval does shrink to zero width, because 1/n→0. The prediction interval does not: its half-width tends to ts→1.96σ, the floor set by the noise in the observation being predicted, which no amount of data about other observations can reduce. A future observation can never be predicted exactly by a model with σ>0.

    Step 4 is correct in premise and wrong in conclusion. The line does pass through the point of means — but that is exactly why the width varies: the line pivots about (xˉ,yˉ​), so slope error has no effect at xˉ and a growing effect away from it. The term (x0​−xˉ)2/Sxx​ is zero at x0​=5 and positive everywhere else; both bands are narrowest at xˉ and flare outward.

    (b) The correct intervals.

    New observation at x0​=5. y^​0​=3 and

    SE=s1+41​+0​=10​1​⋅25​​=22​1​=42​​≈0.354,

    so the interval is 3±4.303×0.354=3±1.52, that is (1.48, 4.52) — more than twice as wide as the student's.

    Mean response at x0​=8. y^​0​=−0.5+5.6=5.1, and (x0​−xˉ)2/Sxx​=9/20, so

    SE=s41​+209​​=10​1​2014​​=1007​​=107​​≈0.265,

    giving 5.1±4.303×0.265=5.1±1.14, that is (3.96, 6.24). Compare the half-width 0.68 at the centre: moving three units from xˉ has widened the mean-response interval by the factor 0.7/0.25​=2.8​≈1.67, which is Step 4 refuted numerically.

  9. 9.Computation

    Write the simple regression of y on x for the four points (2,1),(4,2),(6,4),(8,5) in matrix form, with X having a column of ones and a column of x values, so that p=2.

    1. (a)Write out X⊤X and X⊤y, invert the first, and solve the normal equations. Confirm the scalar answer b0​=−0.5, b1​=0.7, and check that the determinant equals nSxx​.
    2. (b)Read Var(β^​1​), Var(β^​0​) and Cov(β^​0​,β^​1​) off σ2(X⊤X)−1, and check the first two against σ2/Sxx​ and σ2(n1​+xˉ2/Sxx​).
    3. (c)The i-th diagonal entry of the hat matrix is hii​=xi⊤​(X⊤X)−1xi​ where xi⊤​=(1, xi​) is the i-th row of X. Compute all four hii​, verify that they sum to 2, and then prove that tr(H)=p for every design matrix of full column rank. You may use tr(AB)=tr(BA).

    Solution

    (a) The normal equations by hand. With ∑xi​=20, ∑xi2​=4+16+36+64=120, ∑yi​=12 and ∑xi​yi​=2+8+24+40=74,

    X⊤X=(420​20120​),X⊤y=(1274​).

    The determinant is 4×120−202=480−400=80, and nSxx​=4×20=80. ✓ (It is n∑xi2​−(∑xi​)2=nSxx​ in general, the computational formula for the variance.) So

    (X⊤X)−1=801​(120−20​−204​),

    and by the theorem The normal equations and the least-squares solution,

    β^​=801​(120⋅12−20⋅74−20⋅12+4⋅74​)=801​(1440−1480−240+296​)=801​(−4056​)=(−0.50.7​). ✓

    (b) The covariance matrix. By the theorem Mean and variance of the coefficient estimates, Var(β^​)=σ2(X⊤X)−1, so

    Var(β^​1​)=804​σ2=20σ2​=Sxx​σ2​, ✓Var(β^​0​)=80120​σ2=23​σ2,

    and the check: n1​+xˉ2/Sxx​=41​+2025​=41​+45​=23​. ✓ (This is the mean-response variance at x0​=0, since β^​0​=y^​(0).) The off-diagonal entry gives Cov(β^​0​,β^​1​)=−8020​σ2=−4σ2​, which is −xˉσ2/Sxx​=−5σ2/20: with a positive xˉ, overestimating the slope forces the intercept down, because the line must still pass through the point of means.

    (c) Leverages and their sum. For row (1, x),

    h=801​(1​x​)(120−20​−204​)(1x​)=80120−40x+4x2​=20x2−10x+30​=20(x−5)2+5​=41​+Sxx​(x−xˉ)2​,

    which is the familiar bracket from the confidence-interval formula. Evaluating: at x=2 and x=8, h=41​+209​=0.7; at x=4 and x=6, h=41​+201​=0.3. Sum: 0.7+0.3+0.3+0.7=2=p. ✓ The end points carry more leverage — the line is more strongly pulled by them.

    Proof that tr(H)=p. Using the cyclic property with A=X and B=(X⊤X)−1X⊤,

    tr(H)=tr(X(X⊤X)−1X⊤)=tr((X⊤X)−1X⊤X)=tr(Ip​)=p. ■

    Geometrically, by the theorem Least squares is orthogonal projection, H projects onto a p-dimensional subspace, and the trace of a projection is the dimension of its range. The total leverage p is fixed by the model; the data decide only how it is shared out.

  10. 10.Proof

    Two predictors and the response have all been centred, so ∑i​xi1​=∑i​xi2​=∑i​yi​=0 and the intercept may be dropped: the design matrix X has just the two columns x1​,x2​. Write S11​=∑i​xi12​, S22​=∑i​xi22​, S12​=∑i​xi1​xi2​ (all with S11​,S22​>0) and r12​=S12​/S11​S22​​. Assume Var(ε)=σ2I.

    1. (a)Write out X⊤X and prove that it is invertible if and only if ∣r12​∣<1. Relate this to full column rank.
    2. (b)Compute (X⊤X)−1 and prove that Var(β^​1​)=S11​(1−r122​)σ2​.
    3. (c)Regress x1​ on x2​ alone (through the origin, since both are centred). Compute the residual sum of squares of that auxiliary fit and show R12​=r122​. Conclude that VIF1​=1/(1−r122​) and that (b) is exactly the variance-inflation formula in this case.
    4. (d)If r12​=0.8, by what factor is the standard error of β^​1​ larger than it would be with an uncorrelated second predictor, and how many times as many observations would compensate? Say what happens to y^​ and to the bias of β^​1​ as r12​→1.

    Solution

    (a) The Gram matrix and its determinant.

    X⊤X=(x1⊤​x1​x2⊤​x1​​x1⊤​x2​x2⊤​x2​​)=(S11​S12​​S12​S22​​),

    with determinant S11​S22​−S122​=S11​S22​(1−r122​), using S122​=r122​S11​S22​. Since S11​S22​>0, the determinant is non-zero exactly when r122​=1. By Cauchy–Schwarz, S122​≤S11​S22​, so ∣r12​∣≤1 always; hence invertible ⟺∣r12​∣<1. ■

    The equality case of Cauchy–Schwarz is proportionality, x2​=cx1​, which is precisely failure of full column rank. So this is the theorem The normal equations and the least-squares solution in two dimensions: ∣r12​∣=1 means the two columns carry the same information and there is no unique fit.

    (b) Invert and read off the variance. For a 2×2 matrix,

    (X⊤X)−1=S11​S22​(1−r122​)1​(S22​−S12​​−S12​S11​​).

    By the theorem Mean and variance of the coefficient estimates, Var(β^​1​)=σ2[(X⊤X)−1]11​, so

    Var(β^​1​)=σ2⋅S11​S22​(1−r122​)S22​​=S11​(1−r122​)σ2​. ■

    With r12​=0 this is σ2/S11​, the simple-regression variance; every non-zero r12​ inflates it.

    (c) The auxiliary regression. Regressing x1​ on x2​ through the origin minimises ∑i​(xi1​−cxi2​)2=S11​−2cS12​+c2S22​, a quadratic in c with minimum at c=S12​/S22​. Substituting,

    SSEaux​=S11​−2S22​S122​​+S22​S122​​=S11​−S22​S122​​=S11​(1−S11​S22​S122​​)=S11​(1−r122​).

    Because x1​ is centred its total sum of squares is S11​, so

    R12​=1−S11​SSEaux​​=1−(1−r122​)=r122​,

    and VIF1​=1/(1−R12​)=1/(1−r122​). Then (b) reads

    Var(β^​1​)=S11​σ2​⋅1−R12​1​=S11​σ2​VIF1​,

    which is the theorem Variance inflation with p−1=2 predictors, proved rather than quoted. ■ Note also that SSEaux​=∥r1​∥2 is the squared length of the part of x1​ not explained by x2​, and Var(β^​1​)=σ2/∥r1​∥2: the coefficient is estimated from the leftover part alone.

    (d) Numbers, and the limit. With r12​=0.8, VIF1​=1/(1−0.64)=1/0.36=25/9. Standard errors scale as VIF​, so SE(β^​1​) is 5/3 times what it would be with an uncorrelated predictor. Variance falls as 1/n at fixed spread, so compensating would take 25/9≈2.8 times as many observations.

    As r12​→1 the variance of β^​1​ tends to infinity: the two coefficients become individually meaningless, typically large and of opposite sign. But two things do not break. E(β^​1​)=β1​ throughout, by the same theorem — inflation is variance, never bias. And the fitted values y^​=Hy depend only on the column space of X, which is the same plane for every r12​<1; so prediction within the range of the data is unaffected. The data know what the pair predicts; they cannot say which predictor deserves the credit.

  11. 11.Critique

    A model with an intercept and two predictors x1​,x2​ is fitted to n=33 observations, giving SST=160 and SSE=60. The two coefficients have t statistics 1.2 and 1.0, and each predictor has Rj2​=0.96 when regressed on the other. Refitting with x1​ alone gives SSE=62 and a t statistic of 7.0 for x1​. Critical values: t0.025,30​=2.042, t0.025,31​=2.040, F0.05,2,30​=3.32.

    The analyst reports:

    Step 1. R2=1−60/160=0.625, so the model accounts for 62.5% of the variation.

    Step 2. Neither ∣t∣ exceeds 2.042, so neither predictor is associated with y; the 62.5% must be an artefact.

    Step 3. The variance inflation factors are 25, which means each coefficient estimate is biased by a factor of about 25 and cannot be trusted in any case.

    Step 4. Refitting with x1​ alone gives t=7.0, so the effect of x1​ is now established at p<0.001 and x2​ was rightly discarded; since SSE rose only from 60 to 62, the one-predictor model also has the higher adjusted R2.

    1. (a)Compute the overall F statistic for the two-predictor model, the nested F for dropping x2​, and the adjusted R2 of both models, all exactly.
    2. (b)Identify every flaw in Steps 2–4, naming the theorem, remark or pitfall each one violates, and state what the report should have concluded instead.

    Solution

    (a) The numbers the analyst did not compute.

    Overall F. The reduced model is intercept-only, with SSEred​=SST=160 and q=1; the full model has p=3, so n−p=30. By the theorem Nested model comparison,

    F=60/30(160−60)/(3−1)​=250​=25,

    against F0.05,2,30​=3.32. Overwhelmingly significant: the pair of predictors explains far more than chance would.

    Nested F for dropping x2​. F=60/30(62−60)/1​=22​=1, and indeed F=t22​=1.02, as F1,ν​=tν2​ requires. ✓ (Likewise for the refit, F=62/31(160−62)/1​=298​=49=7.02. ✓)

    Adjusted R2. With SST/(n−1)=160/32=5:

    two predictors: 1−560/30​=1−52​=0.6;one predictor: 1−562/31​=1−52​=0.6.

    The two are equal — s2=2 in both models. This is the proposition Adjusted R-squared penalises useless predictors sitting exactly on its boundary: adding a predictor raises Radj2​ if and only if ∣t∣>1, and t2​=1.0 is the break-even case.

    (b) The flaws.

    Step 2: insignificant t's do not mean irrelevant predictors. With Rj2​=0.96 the predictors are nearly interchangeable, and by the theorem Variance inflation each standard error is 25​=5 times what it would be for an uncorrelated predictor. The data cannot apportion credit between x1​ and x2​, so each coefficient, holding the other fixed, is poorly determined. The joint test in (a) says the pair carries a great deal of information, F=25. This is the puzzle in the remark What multicollinearity does and does not break: a highly significant F with no significant coefficient is the signature of collinearity, not of an artefact. The 62.5% is real.

    Step 3: inflation is variance, not bias. The theorem Mean and variance of the coefficient estimates gives E(β^​)=β whatever the correlation among predictors; Gauss–Markov unbiasedness is untouched. What a VIF of 25 says is Var(β^​j​)=25σ2/Sjj​ — the estimate is right on average and imprecise, which is the opposite of “cannot be trusted”. Nor is the factor 25 applied to the estimate: it multiplies the variance, and the standard error by 5.

    Step 4 contains three errors. First, the p-value from the refit is not valid: the model was chosen by looking at these same data, and a coefficient that survived a selection step is biased away from zero because it survived — the pitfall on stepwise selection. Since x1​ and x2​ are near-duplicates, dropping x1​ instead would have produced an equally impressive t for x2​; the choice was arbitrary and the “p<0.001” describes the selection, not x1​. Second, the adjusted R2 claim is simply false — (a) shows the two values are equal, so the criterion is indifferent between the models. Third, “the effect of x1​” is causal language for what is a partial association; nothing in the fit licenses it (the pitfall on coefficients and causes).

    What should have been concluded. The two predictors jointly predict y well (F=25, R2=0.625) and the data cannot say which of them matters. If the goal is prediction inside the observed range, keep both — the fitted values are unaffected by collinearity. If the goal is interpretation, either combine the two into one index, or collect data in which they vary separately, and report any selection that was done as exploratory, with standard errors assessed on data not used to select.

  12. 12.Computation

    For the four points (2,1),(4,2),(6,4),(8,5): xˉ=5, yˉ​=3, Sxx​=20, Syy​=10, Sxy​=14, r2=0.98, s2=0.1, and the regression of y on x is y^​=−0.5+0.7x. You may use 46​≈6.78 and 115​≈10.72.

    1. (a)Fit the regression of x on y. Show that it is not the algebraic inverse of y^​=−0.5+0.7x, and prove in general that the product of the two slopes is r2. When do the two lines coincide?
    2. (b)Compute the standard error of the estimated mean response at x0​=5 and at x0​=20, exactly, and their ratio. Then explain why even the wider interval at x0​=20 understates the real uncertainty there.
    3. (c)Someone reads the slope 0.7 as “increasing x by one unit will increase y by 0.7”. Name three distinct mechanisms that could produce this slope without that being true, and say which of them a residual plot can detect.

    Solution

    (a) The other regression. Minimising horizontal rather than vertical squared distances, the roles of x and y swap:

    slope=Syy​Sxy​​=1014​=57​,intercept=xˉ−57​yˉ​=5−521​=54​,

    so x^=0.8+1.4y. Solving y^​=−0.5+0.7x for x instead gives x=(y+0.5)/0.7=75​+710​y, with slope 10/7≈1.43=1.4. The two are different lines; each is optimal for its own direction of error and neither can be obtained from the other.

    Proof of the product. by∣x​bx∣y​=Sxx​Sxy​​⋅Syy​Sxy​​=Sxx​Syy​Sxy2​​=r2. ■ Here 0.7×1.4=0.98=r2. ✓ The inverse of the first line has slope 1/by∣x​, and the second line has slope r2/by∣x​; they agree exactly when r2=1, that is when the points are collinear (the theorem Correlation lies between −1 and 1). Otherwise the x-on-y line is always the flatter of the two when drawn in the (x,y) plane — regression to the mean in both directions at once.

    (b) The cost of leaving the data. By the theorem Confidence and prediction intervals, SE(y^​0​)=sn1​+(x0​−xˉ)2/Sxx​​ with s=1/10​.

    At x0​=5=xˉ: SE=s1/4​=210​1​=2010​​≈0.16.

    At x0​=20: (x0​−xˉ)2/Sxx​=225/20=45/4, so 41​+445​=223​ and

    SE=10​1​223​​=2023​​=10115​​≈1.07.

    Ratio: 1/423/2​​=46​≈6.8. Twelve units beyond the last observation, the interval for the mean is nearly seven times as wide as at the centre, because the fitted line pivots about (xˉ,yˉ​) and slope error is amplified by the lever arm x0​−xˉ.

    Even so it understates the uncertainty, because the formula is derived assuming the model holds at x0​=20: that E(Y∣x) is still β0​+β1​x out there. The four observations, all in [2,8], contain no information about that. A relationship linear over [2,8] may bend, saturate or reverse beyond it — the parabola of an earlier question fits a line with R2≈0.92 and then departs from it without limit — and no interval built from s and Sxx​ can price a failure of the model's form. The widening is the part of the risk the mathematics can see; the rest is invisible to it.

    (c) Why a coefficient is not an effect. The slope 0.7 describes the conditional mean of y given x in these data. Three mechanisms produce such a slope with no causal path from x to y:

    Confounding — a third variable drives both x and y, so they move together without either moving the other.

    Reverse causation — y drives x. The algebra is symmetric: (a) shows the regression of x on y describes the same four points equally well, and nothing in the fit says which way any influence runs.

    Selection — the four points were included because of their values of both variables, creating an association among those observed that need not exist in the population.

    A residual plot can detect none of them. It checks the LINE conditions — curvature, changing spread, gross non-normality — which concern how well a line describes the conditional mean. All three mechanisms are perfectly compatible with a clean linear conditional mean and an immaculate residual plot. What licenses a causal reading is the design of the study, not the diagnostics of the fit.

← Back to the question sheet

CalcPath·Free university mathematics

SubjectsProblem setsProgressFeedbackAbout