Lably
Skip to content

Ordinary least squares

Method for estimating the unknown parameters in a linear regression model

  • 29 min read
  • 9 chapters

Related on Lably

Through Statistics, Linear least squares and Linear regression

Geometrically, this is seen as the sum of the squared distances, parallel to the axis of the dependent variable, between each data point in the set and the corresponding point on the regression surface—the smaller the differences, the better the model fits the data. The resulting estimator can be expressed by a simple formula, especially in the case of a simple linear regression, in which there is a single regressor on the right side of the regression equation.

The OLS estimator is consistent for the level-one fixed effects when the regressors are exogenous and forms perfect colinearity (rank condition), consistent for the variance estimate of the residuals when regressors have finite fourth moments and—by the Gauss–Markov theorem—optimal in the class of linear unbiased estimators when the errors are homoscedastic and serially uncorrelated. Under these conditions, the method of OLS provides minimum-variance mean-unbiased estimation when the errors have finite variances. Under the additional assumption that the errors are normally distributed with zero mean, OLS is the maximum likelihood estimator that outperforms any non-linear unbiased estimator.

Linear model

Suppose the data consists of n observations {xi,yi}i=1n. Each observation i includes a scalar response yi and a column vector xi of p parameters (regressors), i.e., xi=[xi1,xi2,…,xip]T. In a linear regression model, the response variable, yi, is a linear function of the regressors:

yi=β1xi1+β2xi2+⋯+βpxip+εi,

or in vector form,

yi=xiTβ+εi,

where xi, as introduced previously, is a column vector of the i-th observation of all the explanatory variables; β is a p×1 vector of unknown parameters; and the scalar εi represents unobserved random variables (errors) of the i-th observation. εi accounts for the influences upon the responses yi from sources other than the explanatory variables xi. This model can also be written in matrix notation as

y=Xβ+ε,

where y and ε are n×1 vectors of the response variables and the errors of the n observations, and X is an n×p matrix of regressors, also sometimes called the design matrix, whose row i is xiT and contains the i-th observations on all the explanatory variables.

Typically, a constant term is included in the set of regressors X, say, by taking xi1=1 for all i=1,…,n. The coefficient β1 corresponding to this regressor is called the intercept. Without the intercept, the fitted line is forced to cross the origin when xi=0→.

Regressors do not have to be independent for estimation to be consistent; for example, they may be non-linearly dependent. Short of perfect multicollinearity, parameter estimates may still be consistent; however, as multicollinearity increases the standard errors of such estimates increase, reducing their precision. When there is perfect multicollinearity, it is no longer possible to obtain unique estimates for the coefficients of the related regressors; estimation of these parameters cannot converge and therefore cannot be consistent.

As a concrete example in which regressors are nonlinearly dependent yet estimation may still be consistent, we might suspect that the response depends linearly on both a value and its square; in that case, we would include one regressor whose value is the square of another regressor. The model would then be quadratic in the second regressor but would still be considered a linear model because it remains linear in the parameters (β).

Matrix/vector formulation

Consider an overdetermined system

∑j=1pxijβj=yi,(i=1,2,…,n),

of n linear equations in p unknown coefficients, β1,β2,…,βp, with n>p. This can be written in matrix form as

Xβ=y,

where

X=[X11X12⋯X1pX21X22⋯X2p⋮⋮⋱⋮Xn1Xn2⋯Xnp],β=[β1β2⋮βp],y=[y1y2⋮yn].

(Note: for a linear model as above, not all elements in X contain information on the data points. The first column is populated with ones, Xi1=1. Only the other columns contain actual data. So here p is equal to the number of regressors plus one).

Such a system usually has no exact solution, so the goal is instead to find the coefficients β which fit the equations "best", in the sense of solving the quadratic minimization problem

β^=argminβS(β), where the objective function S is given by:
S(β)=∑i=1n|yi−∑j=1pXijβj|2=‖y−Xβ‖2.

A justification for choosing this criterion is given in Properties below. This minimization problem has a unique solution, provided that the p columns of the matrix X are linearly independent, given by solving the so-called normal equations:

(XTX)β^=XTy.

The matrix XTX is known as the normal matrix or Gram matrix and the matrix XTy is known as the moment matrix of regressand by regressors. Finally, β^ is the coefficient vector of the least-squares hyperplane, expressed as

β^=(X⊤X)−1X⊤y.

or

β^=β+(X⊤X)−1X⊤ε.

Sign in to keep reading

8 more chapters are free with a Lably account.

More in Statistics and probability