Skip to content

Ordinary least squares

Ordinary least squares minimises squared residuals. Fit a factor-return line, track intercept and slope units, and separate rank, inference and causal assumptions.

Ordinary least squares (OLS) estimates the coefficients of a linear regression by minimising the sum of squared differences between observed responses and fitted values. Each observation receives equal weight. In a return regression, this gives a reproducible answer to “which factor exposure and intercept fit these observations best under squared error?” It does not, by itself, establish why returns moved or whether the fitted relationship will persist.
Linear regression describes the model; OLS is a method for fitting its coefficients. “Linear” means linear in those coefficients: a model using predetermined squared or transformed predictors can still be fitted by OLS. NIST explains this distinction.

What the fit minimises

For observations (xi,yi)(x_i,y_i), a simple line with an intercept has fitted values and residuals
y^i=a^+b^xi,ei=yi−y^i.\hat y_i=\hat a+\hat b x_i, \qquad e_i=y_i-\hat y_i.
OLS chooses the two coefficients to minimise the objective function
Q(a,b)=∑i=1n(yi−a−bxi)2.Q(a,b)=\sum_{i=1}^{n}(y_i-a-bx_i)^2.
The residual is a vertical difference in the response variable's units, evaluated at the observed xix_i. OLS does not minimise perpendicular distances to the line, and exchanging response and predictor generally produces a different fit. Squaring prevents positive and negative misses from cancelling and makes large misses particularly influential. Equal weighting distinguishes ordinary least squares from weighted least squares.

Let xˉ\bar x and yˉ\bar y be the sample means. Provided the predictor values are not all equal,

b^=∑i(xi−xˉ)(yi−yˉ)∑i(xi−xˉ)2,a^=yˉ−b^xˉ.\hat b= \frac{\sum_i(x_i-\bar x)(y_i-\bar y)} {\sum_i(x_i-\bar x)^2}, \qquad \hat a=\bar y-\hat b\bar x.
The slope is also sample covariance divided by sample predictor variance, using the same divisor in both. The common divisor cancels. Normality, independence and constant error variance are unnecessary for calculating this fit. NIST derives the coefficient formulas from the least-squares criterion.

A three-month factor fit, with every miss visible

Consider these synthetic monthly excess returns, with the asset and factor measured over the same months and with the same risk-free-return convention. Both columns are recorded in percentage points (pp): an entry of 11 means a return of 1%1\%, or 0.010.01 in decimal-return units.
MonthFactor xix_i (pp)Asset yiy_i (pp)Fitted y^i\hat y_i (pp)Residual eie_i (pp)Squared residual (pp²)
1−1.0−0.8−0.9+0.10.01
20.00.10.3−0.20.04
31.01.61.5+0.10.01

The means are xˉ=0\bar x=0 and yˉ=0.3\bar y=0.3. The centred predictor squared sum is 22 pp², and the centred cross-product sum is 2.42.4 pp². Hence

b^=2.42=1.2,a^=0.3 pp,y^=0.3+1.2x.\hat b=\frac{2.4}{2}=1.2, \qquad \hat a=0.3\text{ pp}, \qquad \hat y=0.3+1.2x.
The residual sum of squares, also called SSE or RSS, is
SSE=0.12+(−0.2)2+0.12=0.06 pp2.\mathrm{SSE}=0.1^2+(-0.2)^2+0.1^2 =0.06\text{ pp}^2.

The middle observation has the largest miss and contributes two-thirds of SSE. Positive residuals mean that the asset return exceeded the line's fitted value; they do not mean that the asset made a positive return. Month 1 has a positive residual despite its negative asset return.

Synthetic monthly factor and asset excess returns in percentage points. The fitted line is y = 0.3 + 1.2x; fitted asset returns are −0.9, 0.3 and 1.5. The enlarged residual panel shows +0.1, −0.2 and +0.1 pp, whose squared sum is 0.06 pp².
Synthetic monthly factor and asset excess returns in percentage points. The fitted line is y = 0.3 + 1.2x; fitted asset returns are −0.9, 0.3 and 1.5. The enlarged residual panel shows +0.1, −0.2 and +0.1 pp, whose squared sum is 0.06 pp².
Original synthetic example. Panel A shows vertical differences from the fitted line; panel B enlarges the residual scale. All return axes use percentage points.
The slope says that a one-percentage-point increase in the factor corresponds to a 1.2-percentage-point increase in the fitted asset return. If this factor is the market's excess return, the slope is the sample market beta. It measures fitted factor sensitivity; it does not alone determine the asset's total volatility.
The intercept is the fitted monthly asset excess return when the factor excess return is zero. It equals the sample mean here because xˉ=0\bar x=0; that equality is not universal. A factor-regression intercept is often called estimated alpha, but these three constructed observations establish no economic alpha, persistent skill or abnormal future return.
Units must travel with the coefficients. Converting both return columns to decimals gives intercept 0.0030.003, unchanged slope 1.21.2, and SSE 0.0000060.000006 in decimal-return squared units. The factor 10,00010{,}000 between the two SSE numbers comes from squaring the unit conversion. The intercept is a monthly quantity; OLS has not annualised it.

Why the minimum and the intercept matter

Differentiating the objective with respect to the intercept and slope gives the normal equations, expressed through the fitted residuals:
∑iei=0,∑ixiei=0.\sum_i e_i=0, \qquad \sum_i x_i e_i=0.

Both hold in the example. They are identities created by the fit, rather than evidence that the underlying economic errors have zero conditional mean. In particular, a zero average residual is guaranteed by an unconstrained OLS intercept even for a badly specified model.

There is a direct minimum certificate for these three observations. Move the intercept from 0.30.3 to 0.3+u0.3+u and the slope from 1.21.2 to 1.2+v1.2+v, using the same percentage-point input convention. Expanding the squares and using the two residual identities gives

Q(0.3+u,1.2+v)=0.06+3u2+2v2.Q(0.3+u,1.2+v)=0.06+3u^2+2v^2.

Every coefficient change raises the objective unless both changes are zero. The fitted line therefore has the unique global minimum for this dataset.

Removing the intercept changes the problem. Here a line forced through zero still has slope 1.21.2, but SSE rises to 0.33 pp² and the residuals no longer sum to zero. Subtracting a risk-free rate from both return series does not automatically justify forcing the factor regression through the origin.

Several factors: uniqueness belongs to the design

For several predictors, collect the response observations into y\mathbf y and the predictor columns into the design matrix XX. Include a column of ones if the model has an intercept. OLS solves

min⁡β∥y−Xβ∥2,X⊤(y−Xβ^)=0.\min_{\boldsymbol\beta}\lVert\mathbf y-X\boldsymbol\beta\rVert^2, \qquad X^\top(\mathbf y-X\hat{\boldsymbol\beta})=0.
The fitted vector is the orthogonal projection of y\mathbf y onto the column space of XX. Coefficients are unique when XX has full column rank. In that case the formal expression is
β^=(X⊤X)−1X⊤y.\hat{\boldsymbol\beta}=(X^\top X)^{-1}X^\top\mathbf y.

A numerical least-squares solver based on QR or SVD is generally preferable to explicitly forming that inverse. Nearly redundant columns can make coefficients unstable even when exact rank is full.

If columns are exactly redundant, coefficient vectors need not be unique, while the fitted values for the observed design remain unique. For a constant predictor xi=cx_i=c, only the combination a+bca+bc is identified. This is why the simple-line formula requires nonzero predictor variation; more rows alone cannot repair a rank-deficient design.

From fitting to inference or causation

A calculated line is an in-sample summary. Each stronger interpretation requires more:

  • Conditional mean. To treat the population line as E[Y∣x]=a+bx\mathbb{E}[Y\mid x]=a+bx, specify a linear conditional expectation, equivalently a zero conditional-mean error for that model. A best linear approximation need not equal a nonlinear conditional mean.
  • Uncertainty. Under a full-rank correctly specified model with zero-mean errors conditional on the design, constant conditional variance and zero cross-observation error covariance give the classical coefficient covariance formula. Independent normal errors conditional on the design additionally justify exact finite-sample normal and Student-tt inference. Normal returns are not a requirement for merely fitting OLS.
  • Financial time series. Heteroskedasticity and autocorrelation can invalidate classical standard errors. Robust or HAC methods address particular covariance problems under their own sampling conditions; they do not cure endogeneity, poor specification or an inadequate sample.
  • Causation. A causal coefficient needs an identification argument, such as a defensible assignment mechanism and control of confounding. Minimising squared residuals supplies none of that argument.
This example has only n−2=1n-2=1 residual degree of freedom. It cannot meaningfully diagnose the assumptions needed for an economic claim. In real work, align observations and units, inspect influential points and residual patterns, and evaluate stability on data outside the fitting sample. An unusually large miss receives substantial weight under squared error, as NIST's discussion of outlier sensitivity warns.
For a first hand calculation, Basic Statistics and Regression is available in full with a free signed-in account. For the derivation, projection geometry and classical coefficient inference, read Linear Regression; its full lesson requires membership, with a public preview.

Sources

Last updated
  • regression
  • least squares
  • factor models
  • residuals
  • estimation
← Back to the glossaryBack to top ↑