MoonSay /Tutorials/Machine Learning Interview #14
Contents
  1. 01Introduction
  2. 02Least squares
  3. 03Unbiasedness
  4. 04Least variance
  5. 05Distribution and confidence
  6. 06Interview follow-ups
  7. 07Common misconceptions
  8. 08Interview questions and model answers
  9. 09Summary
  10. References

05Distribution and confidence

Chapter 4 gave the center of \hat\beta and its spread. To say how confident we can be about the true slope, we need its whole distribution: first in the ideal model, where all five assumptions hold, then for our real patients.

5.1The fifth assumption: the estimate is normal

Definition 3 (Normal errors). Assumption 5 (normal errors). Given X, the errors are independent normal variables with mean 0 and variance \sigma^2: \varepsilon\mid X\sim\mathcal N(0,\sigma^2I).

This contains Assumptions 2–4 and adds the shape. From Chapter 3, \hat\beta=\beta+A\varepsilon (8): the truth plus a weighted sum of the errors, so the shape of \hat\beta comes from the shape of the errors. A weighted sum of normal variables is exactly normal, so

\hat\beta\mid X\sim\mathcal N\bigl(\beta,\;\sigma^2(X^\top X)^{-1}\bigr) \tag{15}

exactly, for any n (Hastie et al., 2009, §3.2): centered on \beta (Chapter 3), with the variance of Chapter 4.

5.2The t distribution and the confidence interval

If \sigma were known, (\hat\beta_j-\beta_j)/(\sigma\sqrt{v_j}), with v_j=[(X^\top X)^{-1}]_{jj}, would be standard normal. But we do not know \sigma: we estimate it from the residuals (12), and that adds a little uncertainty. Under Assumption 5, (n-p-1)\hat\sigma^2/\sigma^2 follows a chi-squared distribution with n-p-1 degrees of freedom and is independent of \hat\beta, and the ratio of a standard normal to the square root of an independent chi-squared divided by its degrees of freedom is, by definition, Student’s t:

t_j=\frac{\hat\beta_j-\beta_j}{\mathrm{SE}(\hat\beta_j)}=\frac{\hat\beta_j-\beta_j}{\hat\sigma\sqrt{v_j}}\;\sim\;t_{n-p-1} , \tag{16}

a bell with slightly heavier tails than the normal (Figure 5a). In the ideal model this holds exactly, even with ten patients. With 442 patients the t distribution is almost normal, and 95\% of it lies within \pm1.97. So

\hat\beta_j\pm t_{0.975,\,n-p-1}\,\mathrm{SE}(\hat\beta_j) \tag{17}

is a 95\% confidence interval: over repeated studies, as in Chapter 3, intervals built this way contain the true \beta_j 95\% of the time. To test whether input j matters at all, set \beta_j=0: t=\hat\beta_j/\mathrm{SE}(\hat\beta_j). The p-value is the chance of a t at least this large in absolute value if \beta_j were really 0; it falls below 5\% exactly when 0 lies outside the 95\% interval.

(a) The t distribution with 440 degrees of freedom (442 patients, two coefficients), almost normal, and with 8 degrees of freedom (ten patients), whose tails are heavier; the shaded middle 95\% lies within \pm1.97. (b) The 95\% confidence interval for the slope of body mass index, with White’s robust standard error; zero is far outside. Computed for this tutorial, with the same data as the companion video.
Figure 5. (a) The t distribution with 440 degrees of freedom (442 patients, two coefficients), almost normal, and with 8 degrees of freedom (ten patients), whose tails are heavier; the shaded middle 95\% lies within \pm1.97. (b) The 95\% confidence interval for the slope of body mass index, with White’s robust standard error; zero is far outside. Computed for this tutorial, with the same data as the companion video.

Worked example 5 (How confident can we be about our slope?). Back to our real patients. Their error variance is not constant (the funnel of Chapter 4), so we use White’s standard error, 0.61, and with 442 patients the interval holds approximately: 10.2\pm1.97\times0.61, from 9.0 to 11.4 points of progression per point of body mass index (Figure 5b). Zero is far outside: strong evidence against a slope of zero. The t test agrees: t=10.2/0.61, about 17, and the p-value is below 10^{-40}. So the data show a strong positive association between body mass index and progression; this regression alone does not prove that one causes the other. Any coefficient works the same way, the intercept too.

5.3What if the errors are not normal?

Figure 6 shows our residuals: roughly normal, but flatter, with lighter tails (fewer extreme values) than a normal distribution, as the bends at the ends of the Q–Q plot show. Are the interval and the test still valid? With 442 patients, yes.

The residuals of the body-mass-index regression. (a) Histogram with the normal density of the same standard deviation. (b) Normal Q–Q plot: sorted residuals against the quantiles of a normal distribution; normal residuals would lie on the line. Computed for this tutorial, with the same data as the companion video.
Figure 6. The residuals of the body-mass-index regression. (a) Histogram with the normal density of the same standard deviation. (b) Normal Q–Q plot: sorted residuals against the quantiles of a normal distribution; normal residuals would lie on the line. Computed for this tutorial, with the same data as the companion video.

Look at (8) once more. With one input, \hat\beta_1-\beta_1=\sum_iw_i\varepsilon_i with w_i=(x_i-\bar x)/S_{xx}: a weighted sum of 442 independent errors, none of which dominates. The central limit theorem says that such a sum is approximately normal whatever the shape of the individual errors. A Galton board makes the same point: each ball bounces left or right at random many times, and the balls pile up in a bell. So for large samples, \hat\beta is approximately normal and (16) holds approximately under Assumptions 1–4 alone; if the variance is not constant, use the robust standard error (14) in the denominator, as Example 5 did.

Normality matters for small samples. With 10 patients the sum has too few terms for the central limit theorem, and the exactness of (16) rests on Assumption 5; heavy-tailed errors or outliers can then make the p-values badly wrong. And it is the errors that should be normal, not x or y. The inputs are taken as given and can have any distribution; the outcome y is often skewed simply because its mean x_i^\top\beta varies from patient to patient.

Pause and think. A colleague finds that the outcome y is strongly skewed and concludes that linear regression cannot be used. What do you say?

Show the answer

The assumption is about the errors given x, not about y. Fit the model and look at the residuals. Even if they are not normal, with a large sample the t tests are approximately valid by the central limit theorem; with a small sample, consider a transformation or a bootstrap.

That completes the ladder. Now, three follow-ups interviewers love.