Contents
Linear Regression AssumptionsWhat Each One Buys
What least squares does, and what each assumption buys
A tutorial companion to the video Machine Learning Interview #14: Linear Regression Assumptions: What Each One Buys PDF
01Introduction
1.1The question
Linear regression is the first model most people learn and still one of the most used: to predict, and even more to explain how an outcome moves with its inputs. Every statistics package reports coefficients, standard errors and p-values for it, and each of those numbers rests on assumptions. “What are the assumptions of linear regression?” tests whether you know them, and above all whether you know what each one is for: which result breaks when it fails, how to see it in the data, and what to do about it.
1.2Prerequisites and notation
Prerequisites. Calculus and linear algebra (matrix transpose, inverse, rank). Expectation, variance and the normal distribution. Maximum likelihood (Episode 5) helps for one follow-up.
Notation. We have n observations; observation i has an outcome y_i and p inputs (predictors, features) x_{i1},\dots,x_{ip}. The design matrix X is n\times(p+1): row i is x_i^\top=(1,x_{i1},\dots,x_{ip}), where the leading 1 carries the intercept. The model is
where \beta=(\beta_0,\dots,\beta_p)^\top are the unknown coefficients and \varepsilon_i is the error: everything about y_i that the inputs do not explain. An estimate is marked with a hat: \hat\beta. The fitted values are \hat y_i=x_i^\top\hat\beta and the residuals are e_i=y_i-\hat y_i. Errors are unobserved; residuals are what we can compute. \mathrm{RSS}=\sum_ie_i^2 is the residual sum of squares. With one input, \bar x and \bar y are the means and S_{xx}=\sum_i(x_i-\bar x)^2.
1.3A short history
On 1 January 1801 Giuseppe Piazzi found a new world, the dwarf planet Ceres, and followed it for about six weeks before it disappeared in the glare of the Sun. Carl Friedrich Gauss, then 24, computed its orbit from those few, noisy observations, and at the end of the year Ceres was found again close to where he had predicted. The method for combining noisy observations that made his name, least squares, was first published by Adrien-Marie Legendre in 1805; Gauss published his version in 1809 and said he had used it since 1795 (Stigler, 1981). In the 1820s Gauss went further and proved, without assuming normal errors, that least squares has the smallest variance among linear unbiased estimates (Plackett, 1949), the result we now call the Gauss–Markov theorem. The word regression comes from Francis Galton, who found that children of unusually tall parents are, on average, less unusual than their parents: their heights “regress” toward the mean (Galton, 1886). Aitken (1936) extended least squares to correlated and unequal errors, and White (1980) showed how to get valid standard errors when the variance is not constant. Textbook treatments are Murphy (2022, §11.2), Hastie et al. (2009, §3.2) and James et al. (2021, Ch. 3).
All examples use one real data set, the diabetes data that Efron et al. (2004) published with their paper on least angle regression: 442 patients, each with ten baseline measurements (age, sex, body mass index, average blood pressure and six blood serum measurements) and a measure of how far the disease had progressed one year later. All numbers in this tutorial were computed for this tutorial, with the same data as the companion video.