Linear Regression
Linear regression models a scalar response as an affine function of one or more inputs . Given a dataset with , the simple linear regression model is
where is the intercept, is the slope, and is a noise term with . The parameters are estimated by ordinary least squares (OLS), minimizing the residual sum of squares
Setting the partial derivatives to zero yields the closed-form estimators
The fitted line always passes through the centroid .The general case with predictors (the multiple linear regression model) writes each observation as and produces the matrix-form OLS solution , covered in its own note.
Under the additional assumption that the noise is i.i.d. Gaussian, , the OLS coefficients coincide with the maximum-likelihood estimates, and the framework gains exact distributional theory for inference: confidence intervals, -tests on individual coefficients, and -tests on groups. The Gauss-Markov theorem says that even without Gaussianity, OLS is the best linear unbiased estimator when the noise is uncorrelated with constant variance.
Intuition
Linear regression is the simplest model that explains how one quantity changes with another. The slope is the expected change in for a unit change in ; the intercept is the expected when . Fitting reduces to minimizing the squared vertical distance between the observed points and the line, which is what least squares means literally. The closed-form solution exists because the squared-error objective is a quadratic in , with a unique minimum that the partial-derivative equations recover exactly.
The estimator has an interpretable structure. The numerator measures how strongly moves with in the data; the denominator rescales by how much varies. So the slope is a normalized covariance, with units of ” per unit of .” If and are uncorrelated, and the best linear prediction is the constant — knowing does not help.
The MLE perspective adds a probabilistic story on top. If the noise really is Gaussian, the likelihood of the data factors into Gaussian densities, and maximizing the log-likelihood is mathematically identical to minimizing the sum of squared errors. So OLS and MLE agree on the regression coefficients; the only thing the Gaussian assumption adds is a closed-form variance estimator and the distributional theory for inference. Without Gaussianity the coefficient estimates remain valid by Gauss-Markov; only the standard errors and -values become approximate (relying on a CLT) rather than exact.
Properties
(Slope and Intercept Estimators) The OLS coefficients have closed-form expressions in terms of sample moments.
Setting and and solving the resulting normal equations gives
The slope is the sample covariance of and divided by the sample variance of ; the intercept is whatever shift makes the line pass through . Both estimators are linear in , which is what makes their distributional properties clean under noise assumptions.
(Population Interpretation) OLS minimizes the population mean-squared prediction error.
Viewing as a random pair, the population objective is minimized at and , the population analogues of the sample formulas. So OLS estimates the parameters of the best linear predictor of from , regardless of whether the true conditional expectation is actually linear. When it is not, OLS still recovers the linear approximation that minimizes squared error.
(Variance Decomposition) Total variability in splits into explained and residual parts.
The identity decomposes the total sum of squares (SST) into the regression sum of squares (SSR, explained by the fit) and the residual sum of squares (SSE, left over). The decomposition is a Pythagorean identity from the orthogonality of the residual vector to the fitted vector, and it is the foundation of the coefficient of determination
the fraction of ‘s variability captured by the regression. In simple regression equals the squared sample correlation between and .
(Maximum Likelihood Under Gaussian Noise) OLS coincides with the MLE when .
Under the Gaussian noise assumption, each is independently , and the log-likelihood is
Maximizing over is identical to minimizing the sum of squared errors, so the MLE coefficients are the OLS coefficients exactly. Maximizing over gives the biased estimator ; the unbiased version divides by instead, the residual sum of squares per degree of freedom remaining after fitting two parameters.
(Gauss-Markov Theorem) OLS is the best linear unbiased estimator under uncorrelated, constant-variance noise.
Without any distributional assumption beyond and , no other linear unbiased estimator of has smaller variance than OLS. The result does not require Gaussianity; it relies only on the noise covariance being scalar. When the noise is correlated or heteroskedastic (), the BLUE becomes the generalized least squares estimator .
(Inference Under Normality) Coefficients have a -distribution.
If the Gaussian noise assumption holds, , and the standardized statistic follows a distribution under . This gives exact-finite-sample -values and confidence intervals. Without Gaussianity, the same statistic is approximately Normal by the central limit theorem when is large, and the -tables remain a good approximation.
(Residual Diagnostics) Plot the residuals before trusting the fit.
The standard checks after fitting are: a residual vs. fitted plot to spot heteroskedasticity (fanning) or model misspecification (curvature), a Q-Q plot of residuals against the Normal distribution to check the noise assumption, and a serial-correlation diagnostic (e.g., the ACF of residuals) when the data are sequential. Non-trivial structure in the residuals signals that the linear-Gaussian assumptions are broken and the standard errors are unreliable.
Examples
Heights of fathers and sons
Pairs of father-son heights are recorded for families. Fit and interpret.
Solution measures how many inches taller a son is, on average, when his father is one inch taller. Galton's classic finding was , much less than 1: tall fathers tend to have sons closer to the population mean than they themselves are. This is the original "regression to the mean" observation that gave the technique its name. The intercept then absorbs whatever shift makes the line pass through the data centroid.
Predicting house price from square footage
is the sale price in thousands of dollars; is the square footage. After fitting OLS on houses, and with standard errors and .
Interpretation thousand dollars ($180) to the predicted price, with confidence interval roughly . The intercept of $30k is the predicted price of a hypothetical zero-square-foot house, which is not physically meaningful but allows the line to fit the data; the large standard error on the intercept reflects that the data probably do not extend down to . The corresponding would tell you the fraction of price variance the model explains, e.g., would mean square footage alone explains 65% of the price variation.
Each additional square foot adds
See Also
- 1.2a. Multiple Linear Regression: the matrix-form generalization to many predictors.
- 1.4. Nonlinear Regression: when the response is not linear in the parameters.
- 1.5. Regularization: ridge and lasso for high-dimensional or correlated designs.
- 1.6. Cross-Validation: model-selection machinery for regression and classification.
- 3.8.1 Bayesian Linear Regression: the Bayesian counterpart, where has a prior and the output is a posterior distribution.
- 2.4 Time Series Regression: how OLS adapts to time series with correlated errors and time-indexed predictors.
- 1.2.3 Linear Least Squares Estimation: the inferential framework’s treatment of linear least squares.