Ordinary least squares explained

In statistics, ordinary least squares (OLS) is a type of linear least squares method for choosing the unknown parameters in a linear regression model (with fixed level-one effects of a linear function of a set of explanatory variables) by the principle of least squares: minimizing the sum of the squares of the differences between the observed dependent variable (values of the variable being observed) in the input dataset and the output of the (linear) function of the independent variable. Some sources consider OLS to be linear regression.[1]

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[2] and—by the Gauss–Markov theoremoptimal 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

See main article: Linear regression model. Suppose the data consists of

n

observations

\left\{xi,yi\right\}

n
i=1
. Each observation

i

includes a scalar response

yi

and a column vector

xi

of

p

parameters (regressors), i.e.,

xi=\left[xi1,xi2,...,xip\right]\operatorname{T}

. In a linear regression model, the response variable,

yi

, is a linear function of the regressors:

yi=\beta1 xi1+\beta2 xi2++\betapxip+\varepsiloni,

or in vector form,

yi=

\operatorname{T}
x
i

\boldsymbol{\beta}+\varepsiloni,

where

xi

, as introduced previously, is a column vector of the

i

-th observation of all the explanatory variables;

\boldsymbol{\beta}

is a

p x 1

vector of unknown parameters; and the scalar

\varepsiloni

represents unobserved random variables (errors) of the

i

-th observation.

\varepsiloni

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\boldsymbol{\beta}+\boldsymbol{\varepsilon},

where

y

and

\boldsymbol{\varepsilon}

are

n x 1

vectors of the response variables and the errors of the

n

observations, and

X

is an

n x p

matrix of regressors, also sometimes called the design matrix, whose row

i

is
\operatorname{T}
x
i
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

\beta1

corresponding to this regressor is called the intercept. Without the intercept, the fitted line is forced to cross the origin when

xi=\vec{0}

.

Regressors do not have to be independent for estimation to be consistent, but multicolinearity makes estimation inconsistent. As a concrete example where regressors are not independent, we might suspect the response depends linearly both on a value and its square; in which case we would include one regressor whose value is just the square of another regressor. In that case, the model would be quadratic in the second regressor, but none-the-less is still considered a linear model because the model is still linear in the parameters (

\boldsymbol{\beta}

).

Matrix/vector formulation

Consider an overdetermined system

p
\sum
j=1

xij\betaj=yi,(i=1,2,...,n),

of

n

linear equations in

p

unknown coefficients,

\beta1,\beta2,...,\betap

, with

n>p

. This can be written in matrix form as

X\boldsymbol{\beta}=y,

where

X=\begin{bmatrix} X11&X12&&X1p\\ X21&X22&&X2p\\ \vdots&\vdots&\ddots&\vdots\\ Xn1&Xn2&&Xnp\end{bmatrix},    \boldsymbol\beta=\begin{bmatrix} \beta1\\beta2\\vdots\\betap \end{bmatrix},    y=\begin{bmatrix} y1\y2\\vdots\yn \end{bmatrix}.

(Note: for a linear model as above, not all elements in

X

contains 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

\boldsymbol{\beta}

which fit the equations "best", in the sense of solving the quadratic minimization problem

\hat{\boldsymbol{\beta}}=\underset{\boldsymbol{\beta}}{\operatorname{argmin}}S(\boldsymbol{\beta}),

where the objective function

S

is given by

S(\boldsymbol{\beta})=

n
\sum
i=1

\left|yi-

p
\sum
j=1

Xij

2
\beta
j\right|

=\left\|y-X\boldsymbol\beta\right\|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:

\left(X\operatorname{T

} \mathbf \right)\hat = \mathbf^ \mathbf y\ .

The matrix

X\operatorname{T

} \mathbf is known as the normal matrix or Gram matrix and the matrix

X\operatorname{T

} \mathbf y is known as the moment matrix of regressand by regressors.[3] Finally,

\hat{\boldsymbol{\beta}}

is the coefficient vector of the least-squares hyperplane, expressed as

\hat{\boldsymbol{\beta}}=\left(X\operatorname{T

} \mathbf \right)^ \mathbf^ \mathbf y.

or

\hat{\boldsymbol{\beta}}=\boldsymbol{\beta}+\left(X\operatorname{T}X\right)-1X\operatorname{T}\boldsymbol{\varepsilon}.

Estimation

Suppose b is a "candidate" value for the parameter vector β. The quantity, called the residual for the i-th observation, measures the vertical distance between the data point and the hyperplane, and thus assesses the degree of fit between the actual data and the model. The sum of squared residuals (SSR) (also called the error sum of squares (ESS) or residual sum of squares (RSS))[4] is a measure of the overall model fit:

S(b)=

n
\sum
i=1

(yi-

\operatorname{T}
x
i

b)2=(y-Xb)\operatorname{T}(y-Xb),

where T denotes the matrix transpose, and the rows of X, denoting the values of all the independent variables associated with a particular value of the dependent variable, are Xi = xiT. The value of b which minimizes this sum is called the OLS estimator for β. The function S(b) is quadratic in b with positive-definite Hessian, and therefore this function possesses a unique global minimum at

b=\hat\beta

, which can be given by the explicit formula:[proof]

\hat\beta=

\operatorname{argmin}
b\inRp

S(b)=(X\operatorname{T}X)-1X\operatorname{T}y.

The product N=XT X is a Gram matrix and its inverse, Q=N–1, is the cofactor matrix of β,[5] [6] [7] closely related to its covariance matrix, Cβ.The matrix (XT X)–1 XT=Q XT is called the Moore–Penrose pseudoinverse matrix of X. This formulation highlights the point that estimation can be carried out if, and only if, there is no perfect multicollinearity between the explanatory variables (which would cause the gram matrix to have no inverse).

After we have estimated β, the fitted values (or predicted values) from the regression will be

\hat{y}=X\hat\beta=Py,

where P = X(XTX)−1XT is the projection matrix onto the space V spanned by the columns of X. This matrix P is also sometimes called the hat matrix because it "puts a hat" onto the variable y. Another matrix, closely related to P is the annihilator matrix ; this is a projection matrix onto the space orthogonal to V. Both matrices P and M are symmetric and idempotent (meaning that and), and relate to the data matrix X via identities and . Matrix M creates the residuals from the regression:

\hat\varepsilon=y-\haty=y-X\hat\beta=My=M(X\beta+\varepsilon)=(MX)\beta+M\varepsilon=M\varepsilon.

Using these residuals we can estimate the value of σ 2 using the reduced chi-squared statistic:

s2=

\hat\varepsilonT\hat\varepsilon
n-p

=

(My)TMy
n-p

=

yTMTMy
n-p

=

yTMy
n-p

=

S(\hat\beta)
n-p

,    \hat\sigma2=

n-p
n

s2

The denominator, np, is the statistical degrees of freedom. The first quantity, s2, is the OLS estimate for σ2, whereas the second, \scriptstyle\hat\sigma^2, is the MLE estimate for σ2. The two estimators are quite similar in large samples; the first estimator is always unbiased, while the second estimator is biased but has a smaller mean squared error. In practice s2 is used more often, since it is more convenient for the hypothesis testing. The square root of s2 is called the regression standard error,[8] standard error of the regression,[9] [10] or standard error of the equation.

It is common to assess the goodness-of-fit of the OLS regression by comparing how much the initial variation in the sample can be reduced by regressing onto X. The coefficient of determination R2 is defined as a ratio of "explained" variance to the "total" variance of the dependent variable y, in the cases where the regression sum of squares equals the sum of squares of residuals:

R2=

\sum(\hatyi-\overline{y
)
2}
i-\overline{y})

=

yTPTLPy
yTLy

=1-

yTMy
yTLy

=1-

\rmRSS
\rmTSS

where TSS is the total sum of squares for the dependent variable, L=I_n-\fracJ_n, and J_n is an n×n matrix of ones. (

L

is a centering matrix which is equivalent to regression on a constant; it simply subtracts the mean from a variable.) In order for R2 to be meaningful, the matrix X of data on regressors must contain a column vector of ones to represent the constant whose coefficient is the regression intercept. In that case, R2 will always be a number between 0 and 1, with values close to 1 indicating a good degree of fit.

The variance in the prediction of the independent variable as a function of the dependent variable is given in the article Polynomial least squares.

Simple linear regression model

See main article: Simple linear regression. If the data matrix X contains only two variables, a constant and a scalar regressor xi, then this is called the "simple regression model". This case is often considered in the beginner statistics classes, as it provides much simpler formulas even suitable for manual calculation. The parameters are commonly denoted as :

yi=\alpha+\betaxi+\varepsiloni.

The least squares estimates in this case are given by simple formulas

\begin{align} \widehat\beta&=

n{(x
\sum
i-\bar{x
)(y

i-\bar{y})}}{

2}}
\sum
i-\bar{x})

\\[2pt] \widehat\alpha&=\bar{y}-\widehat\beta\bar{x}, \end{align}

Alternative derivations

In the previous section the least squares estimator

\hat\beta

was obtained as a value that minimizes the sum of squared residuals of the model. However it is also possible to derive the same estimator from other approaches. In all cases the formula for OLS estimator remains the same: ; the only difference is in how we interpret this result.

Projection

For mathematicians, OLS is an approximate solution to an overdetermined system of linear equations, where β is the unknown. Assuming the system cannot be solved exactly (the number of equations n is much larger than the number of unknowns p), we are looking for a solution that could provide the smallest discrepancy between the right- and left- hand sides. In other words, we are looking for the solution that satisfies

\hat\beta={\rmarg}min\beta\lVerty-X\boldsymbol\beta\rVert,

where is the standard L2 norm in the n-dimensional Euclidean space Rn. The predicted quantity is just a certain linear combination of the vectors of regressors. Thus, the residual vector will have the smallest length when y is projected orthogonally onto the linear subspace spanned by the columns of X. The OLS estimator \hat\beta in this case can be interpreted as the coefficients of vector decomposition of along the basis of X.

In other words, the gradient equations at the minimum can be written as:

(y-X\hat{\boldsymbol{\beta}})\topX=0.

A geometrical interpretation of these equations is that the vector of residuals,

y-X\hat{\boldsymbol{\beta}}

is orthogonal to the column space of X, since the dot product

(y-X\hat{\boldsymbol{\beta}})Xv

is equal to zero for any conformal vector, v. This means that

y-X\boldsymbol{\hat\beta}

is the shortest of all possible vectors

y-X\boldsymbol\beta

, that is, the variance of the residuals is the minimum possible. This is illustrated at the right.

Introducing

\hat{\boldsymbol{\gamma}}

and a matrix K with the assumption that a matrix

[XK]

is non-singular and KT X = 0 (cf. Orthogonal projections), the residual vector should satisfy the following equation:

\hat{r

} := \mathbf - \mathbf \hat = \mathbf \hat.The equation and solution of linear least squares are thus described as follows:

\begin{align} y&=\begin{bmatrix}X&K\end{bmatrix}\begin{bmatrix}\hat{\boldsymbol{\beta}}\\hat{\boldsymbol{\gamma}}\end{bmatrix},\\ {}\begin{bmatrix}\hat{\boldsymbol{\beta}}\\hat{\boldsymbol{\gamma}}\end{bmatrix}&=\begin{bmatrix}X&K\end{bmatrix}-1y=\begin{bmatrix}\left(X\topX\right)-1X\top\\left(K\topK\right)-1K\top\end{bmatrix}y. \end{align}

Another way of looking at it is to consider the regression line to be a weighted average of the lines passing through the combination of any two points in the dataset.[11] Although this way of calculation is more computationally expensive, it provides a better intuition on OLS.

Maximum likelihood

The OLS estimator is identical to the maximum likelihood estimator (MLE) under the normality assumption for the error terms.[proof] This normality assumption has historical importance, as it provided the basis for the early work in linear regression analysis by Yule and Pearson. From the properties of MLE, we can infer that the OLS estimator is asymptotically efficient (in the sense of attaining the Cramér–Rao bound for variance) if the normality assumption is satisfied.

Generalized method of moments

In iid case the OLS estimator can also be viewed as a GMM estimator arising from the moment conditions

E[xi\left(yi-

\operatorname{T}
x
i

\beta\right)]=0.

These moment conditions state that the regressors should be uncorrelated with the errors. Since xi is a p-vector, the number of moment conditions is equal to the dimension of the parameter vector β, and thus the system is exactly identified. This is the so-called classical GMM case, when the estimator does not depend on the choice of the weighting matrix.

Note that the original strict exogeneity assumption implies a far richer set of moment conditions than stated above. In particular, this assumption implies that for any vector-function, the moment condition will hold. However it can be shown using the Gauss–Markov theorem that the optimal choice of function is to take, which results in the moment equation posted above.

Properties

Assumptions

There are several different frameworks in which the linear regression model can be cast in order to make the OLS technique applicable. Each of these settings produces the same formulas and same results. The only difference is the interpretation and the assumptions which have to be imposed in order for the method to give meaningful results. The choice of the applicable framework depends mostly on the nature of data in hand, and on the inference task which has to be performed.

One of the lines of difference in interpretation is whether to treat the regressors as random variables, or as predefined constants. In the first case (random design) the regressors xi are random and sampled together with the yis from some population, as in an observational study. This approach allows for more natural study of the asymptotic properties of the estimators. In the other interpretation (fixed design), the regressors X are treated as known constants set by a design, and y is sampled conditionally on the values of X as in an experiment. For practical purposes, this distinction is often unimportant, since estimation and inference is carried out while conditioning on X. All results stated in this article are within the random design framework.

Classical linear regression model

The classical model focuses on the "finite sample" estimation and inference, meaning that the number of observations n is fixed. This contrasts with the other approaches, which study the asymptotic behavior of OLS, and in which the behavior at a large number of samples is studied.

Independent and identically distributed (iid)

In some applications, especially with cross-sectional data, an additional assumption is imposed — that all observations are independent and identically distributed. This means that all observations are taken from a random sample which makes all the assumptions listed earlier simpler and easier to interpret. Also this framework allows one to state asymptotic results (as the sample size), which are understood as a theoretical possibility of fetching new independent observations from the data generating process. The list of assumptions in this case is:

Time series model

Finite sample properties

First of all, under the strict exogeneity assumption the OLS estimators \scriptstyle\hat\beta and s2 are unbiased, meaning that their expected values coincide with the true values of the parameters:[proof]

\operatorname{E}[\hat\beta\midX]=\beta,\operatorname{E}[s2\midX]=\sigma2.

If the strict exogeneity does not hold (as is the case with many time series models, where exogeneity is assumed only with respect to the past shocks but not the future ones), then these estimators will be biased in finite samples.

The variance-covariance matrix (or simply covariance matrix) of \scriptstyle\hat\beta is equal to

\operatorname{Var}[\hat\beta\midX]=\sigma2\left(X\operatorname{T}X\right)-1=\sigma2Q.

In particular, the standard error of each coefficient \scriptstyle\hat\beta_j is equal to square root of the j-th diagonal element of this matrix. The estimate of this standard error is obtained by replacing the unknown quantity σ2 with its estimate s2. Thus,

\widehat{\operatorname{s.e.}}(\hat{\beta}j)=\sqrt{s2\left(X\operatorname{T}

-1
X\right)
jj
}

It can also be easily shown that the estimator \scriptstyle\hat\beta is uncorrelated with the residuals from the model:

\operatorname{Cov}[\hat\beta,\hat\varepsilon\midX]=0.

The Gauss–Markov theorem states that under the spherical errors assumption (that is, the errors should be uncorrelated and homoscedastic) the estimator \scriptstyle\hat\beta is efficient in the class of linear unbiased estimators. This is called the best linear unbiased estimator (BLUE). Efficiency should be understood as if we were to find some other estimator \scriptstyle\tilde\beta which would be linear in y and unbiased, then

\operatorname{Var}[\tilde\beta\midX]-\operatorname{Var}[\hat\beta\midX]\geq0

in the sense that this is a nonnegative-definite matrix. This theorem establishes optimality only in the class of linear unbiased estimators, which is quite restrictive. Depending on the distribution of the error terms ε, other, non-linear estimators may provide better results than OLS.

Assuming normality

The properties listed so far are all valid regardless of the underlying distribution of the error terms. However, if you are willing to assume that the normality assumption holds (that is, that), then additional properties of the OLS estimators can be stated.

The estimator \scriptstyle\hat\beta is normally distributed, with mean and variance as given before:[14]

\hat\beta\siml{N}(\beta, \sigma2(XTX)-1).

This estimator reaches the Cramér–Rao bound for the model, and thus is optimal in the class of all unbiased estimators. Note that unlike the Gauss–Markov theorem, this result establishes optimality among both linear and non-linear estimators, but only in the case of normally distributed error terms.

The estimator s2 will be proportional to the chi-squared distribution:

2 \sim\sigma2
n-p
s

2
\chi
n-p

The variance of this estimator is equal to, which does not attain the Cramér–Rao bound of . However it was shown that there are no unbiased estimators of σ2 with variance smaller than that of the estimator s2.[15] If we are willing to allow biased estimators, and consider the class of estimators that are proportional to the sum of squared residuals (SSR) of the model, then the best (in the sense of the mean squared error) estimator in this class will be, which even beats the Cramér–Rao bound in case when there is only one regressor .

Moreover, the estimators \scriptstyle\hat\beta and s2 are independent, the fact which comes in useful when constructing the t- and F-tests for the regression.

Influential observations

See main article: Influential observation.

See also: Leverage (statistics).

As was mentioned before, the estimator

\hat\beta

is linear in y, meaning that it represents a linear combination of the dependent variables yi. The weights in this linear combination are functions of the regressors X, and generally are unequal. The observations with high weights are called influential because they have a more pronounced effect on the value of the estimator.

To analyze which observations are influential we remove a specific j-th observation and consider how much the estimated quantities are going to change (similarly to the jackknife method). It can be shown that the change in the OLS estimator for β will be equal to [16]

\hat\beta(j)-\hat\beta=-

1
1-hj

(XTX)-1

T
x
j

\hat\varepsilonj,

where is the j-th diagonal element of the hat matrix P, and xj is the vector of regressors corresponding to the j-th observation. Similarly, the change in the predicted value for j-th observation resulting from omitting that observation from the dataset will be equal to [16]
(j)
\hat{y}
j

-\hat{y}j=

T
x
j

\hat\beta(j)-

\operatorname{T}
x
j

\hat\beta=-

hj
1-hj

\hat\varepsilonj

From the properties of the hat matrix,, and they sum up to p, so that on average . These quantities hj are called the leverages, and observations with high hj are called leverage points. Usually the observations with high leverage ought to be scrutinized more carefully, in case they are erroneous, or outliers, or in some other way atypical of the rest of the dataset.

Partitioned regression

Sometimes the variables and corresponding parameters in the regression can be logically split into two groups, so that the regression takes form

y=X1\beta1+X2\beta2+\varepsilon,

where X1 and X2 have dimensions n×p1, n×p2, and β1, β2 are p1×1 and p2×1 vectors, with .

The Frisch–Waugh–Lovell theorem states that in this regression the residuals \hat\varepsilon and the OLS estimate \scriptstyle\hat\beta_2 will be numerically identical to the residuals and the OLS estimate for β2 in the following regression:

M1y=M1X2\beta2+η,

where M1 is the annihilator matrix for regressors X1.

The theorem can be used to establish a number of theoretical results. For example, having a regression with a constant and another regressor is equivalent to subtracting the means from the dependent variable and the regressor and then running the regression for the de-meaned variables but without the constant term.

Constrained estimation

See main article: Ridge regression.

Suppose it is known that the coefficients in the regression satisfy a system of linear equations

A\colonQ\operatorname{T}\beta=c,

where Q is a p×q matrix of full rank, and c is a q×1 vector of known constants, where . In this case least squares estimation is equivalent to minimizing the sum of squared residuals of the model subject to the constraint A. The constrained least squares (CLS) estimator can be given by an explicit formula:

\hat\betac=\hat\beta-(X\operatorname{T}X)-1Q(Q\operatorname{T}(X\operatorname{T}X)-1Q)-1(Q\operatorname{T}\hat\beta-c).

This expression for the constrained estimator is valid as long as the matrix XTX is invertible. It was assumed from the beginning of this article that this matrix is of full rank, and it was noted that when the rank condition fails, β will not be identifiable. However it may happen that adding the restriction A makes β identifiable, in which case one would like to find the formula for the estimator. The estimator is equal to

\hat\betac=R(R\operatorname{T}X\operatorname{T}XR)-1R\operatorname{T}X\operatorname{T}y+(Ip-R(R\operatorname{T}X\operatorname{T}XR)-1R\operatorname{T}X\operatorname{T}X)Q(Q\operatorname{T}Q)-1c,

where R is a p×(p − q) matrix such that the matrix is non-singular, and . Such a matrix can always be found, although generally it is not unique. The second formula coincides with the first in case when XTX is invertible.

Large sample properties

The least squares estimators are point estimates of the linear regression model parameters β. However, generally we also want to know how close those estimates might be to the true values of parameters. In other words, we want to construct the interval estimates.

Since we have not made any assumption about the distribution of error term εi, it is impossible to infer the distribution of the estimators

\hat\beta

and

\hat\sigma2

. Nevertheless, we can apply the central limit theorem to derive their asymptotic properties as sample size n goes to infinity. While the sample size is necessarily finite, it is customary to assume that n is "large enough" so that the true distribution of the OLS estimator is close to its asymptotic limit.

We can show that under the model assumptions, the least squares estimator for β is consistent (that is

\hat\beta

converges in probability to β) and asymptotically normal:[proof]

(\hat\beta-

-1
\beta)\xrightarrow{d}l{N}(0, \sigma
xx

),

where

Qxx=X\operatorname{T}X.

Intervals

See main article: Confidence interval and Prediction interval.

Using this asymptotic distribution, approximate two-sided confidence intervals for the j-th component of the vector

\hat{\beta}

can be constructed as

\betaj\in[ \hat\betaj\pmql{N(0,

1)}
1-
\alpha
2

\sqrt{\hat{\sigma}2

-1
\left[Q
xx

\right]jj

}\ \bigg]   at the confidence level,where q denotes the quantile function of standard normal distribution, and [·]jj is the j-th diagonal element of a matrix.

Similarly, the least squares estimator for σ2 is also consistent and asymptotically normal (provided that the fourth moment of εi exists) with limiting distribution

(\hat{\sigma}2-

4\right]
\sigma
i

-\sigma4\right).

These asymptotic distributions can be used for prediction, testing hypotheses, constructing other estimators, etc.. As an example consider the problem of prediction. Suppose

x0

is some point within the domain of distribution of the regressors, and one wants to know what the response variable would have been at that point. The mean response is the quantity

y0=

T
x
0

\beta

, whereas the predicted response is

\hat{y}0=

T
x
0

\hat\beta

. Clearly the predicted response is a random variable, its distribution can be derived from that of

\hat{\beta}

:

\left(\hat{y}0-

2
y
0\right)\xrightarrow{d}l{N}\left(0, \sigma
T
x
0
-1
Q
xx

x0\right),

which allows construct confidence intervals for mean response

y0

to be constructed:

y0\in

T
\left[x
0

\hat{\beta}\pmql{N(0,

1)}
1-
\alpha
2

\sqrt{\hat\sigma2

T
x
0
-1
Q
xx

x0}\right]

  at the confidence level.

Hypothesis testing

See main article: Hypothesis testing.

Two hypothesis tests are particularly widely used. First, one wants to know if the estimated regression equation is any better than simply predicting that all values of the response variable equal its sample mean (if not, it is said to have no explanatory power). The null hypothesis of no explanatory value of the estimated regression is tested using an F-test. If the calculated F-value is found to be large enough to exceed its critical value for the pre-chosen level of significance, the null hypothesis is rejected and the alternative hypothesis, that the regression has explanatory power, is accepted. Otherwise, the null hypothesis of no explanatory power is accepted.

Second, for each explanatory variable of interest, one wants to know whether its estimated coefficient differs significantly from zero—that is, whether this particular explanatory variable in fact has explanatory power in predicting the response variable. Here the null hypothesis is that the true coefficient is zero. This hypothesis is tested by computing the coefficient's t-statistic, as the ratio of the coefficient estimate to its standard error. If the t-statistic is larger than a predetermined value, the null hypothesis is rejected and the variable is found to have explanatory power, with its coefficient significantly different from zero. Otherwise, the null hypothesis of a zero value of the true coefficient is accepted.

In addition, the Chow test is used to test whether two subsamples both have the same underlying true coefficient values. The sum of squared residuals of regressions on each of the subsets and on the combined data set are compared by computing an F-statistic; if this exceeds a critical value, the null hypothesis of no difference between the two subsets is rejected; otherwise, it is accepted.

Example with real data

The following data set gives average heights and weights for American women aged 30–39 (source: The World Almanac and Book of Facts, 1975).

Height (m)1.47 1.50 1.52 1.55 1.57
Weight (kg)52.21 53.12 54.48 55.84 57.20
Height (m)1.60 1.63 1.65 1.68 1.70
Weight (kg)58.57 59.93 61.29 63.11 64.47
Height (m)1.73 1.75 1.78 1.80 1.83
Weight (kg)66.28 68.10 69.92 72.19 74.46

When only one dependent variable is being modeled, a scatterplot will suggest the form and strength of the relationship between the dependent variable and regressors. It might also reveal outliers, heteroscedasticity, and other aspects of the data that may complicate the interpretation of a fitted regression model. The scatterplot suggests that the relationship is strong and can be approximated as a quadratic function. OLS can handle non-linear relationships by introducing the regressor 2. The regression model then becomes a multiple linear model:

wi=\beta1+\beta2hi+\beta3

2
h
i

+\varepsiloni.

The output from most popular statistical packages will look similar to this:

Method Least squares
Dependent variable WEIGHT
Observations 15

Parameter ValueStd errort-statisticp-value

\beta1

128.8128 16.3083 7.8986 0.0000

\beta2

–143.1620 19.8332 –7.2183 0.0000

\beta3

61.9603 6.0084 10.3122 0.0000

0.9989S.E. of regression 0.2516
Adjusted R2 0.9987Model sum-of-sq. 692.61
Log-likelihood 1.0890Residual sum-of-sq. 0.7595
2.1013Total sum-of-sq. 693.37
0.2548F-statistic 5471.2
Schwarz criterion 0.3964p-value (F-stat) 0.0000

In this table:

\hat\sigmaj=

-1
\left(\hat{\sigma}
xx

\right]jj

1
2
\right)

t=\hat\betaj/\hat\sigmaj

. If the errors ε follow a normal distribution, t follows a Student-t distribution. Under weaker conditions, t is asymptotically normal. Large values of t indicate that the null hypothesis can be rejected and that the corresponding coefficient is not zero. The second column, p-value, expresses the results of the hypothesis test as a significance level. Conventionally, p-values smaller than 0.05 are taken as evidence that the population coefficient is nonzero.

R2

, designed to penalize for the excess number of regressors which do not add to the explanatory power of the regression. This statistic is always smaller than

R2

, can decrease as new regressors are added, and even be negative for poorly fitting models:

\overline{R}2=1-

n-1
n-p

(1-R2)

Ordinary least squares analysis often includes the use of diagnostic plots designed to detect departures of the data from the assumed form of the model. These are some of the common diagnostic plots:

\hat{y}

.

An important consideration when carrying out statistical inference using regression models is how the data were sampled. In this example, the data are averages rather than measurements on individual women. The fit of the model is very good, but this does not imply that the weight of an individual woman can be predicted with high accuracy based only on her height.

Sensitivity to rounding

See main article: Errors-in-variables models.

This example also demonstrates that coefficients determined by these calculations are sensitive to how the data is prepared. The heights were originally given rounded to the nearest inch and have been converted and rounded to the nearest centimetre. Since the conversion factor is one inch to 2.54 cm this is not an exact conversion. The original inches can be recovered by Round(x/0.0254) and then re-converted to metric without rounding. If this is done the results become:

Const Height Height2
Converted to metric with rounding.128.8128 −143.162 61.96033
Converted to metric without rounding.119.0205 −131.5076 58.5046

Using either of these equations to predict the weight of a 5' 6" (1.6764 m) woman gives similar values: 62.94 kg with rounding vs. 62.98 kg without rounding. Thus a seemingly small variation in the data has a real effect on the coefficients but a small effect on the results of the equation.

While this may look innocuous in the middle of the data range it could become significant at the extremes or in the case where the fitted model is used to project outside the data range (extrapolation).

This highlights a common error: this example is an abuse of OLS which inherently requires that the errors in the independent variable (in this case height) are zero or at least negligible. The initial rounding to nearest inch plus any actual measurement errors constitute a finite and non-negligible error. As a result, the fitted parameters are not the best estimates they are presumed to be. Though not totally spurious the error in the estimation will depend upon relative size of the x and y errors.

Another example with less real data

Problem statement

We can use the least square mechanism to figure out the equation of a two body orbit in polar base co-ordinates. The equation typically used is

r(\theta)=

p
1-e\cos(\theta)
where

r(\theta)

is the radius of how far the object is from one of the bodies. In the equation the parameters

p

and

e

are used to determine the path of the orbit. We have measured the following data.

\theta

(in degrees)
43455293108116

r(\theta)

4.71264.55424.04192.21871.89101.7599
We need to find the least-squares approximation of

e

and

p

for the given data.

Solution

First we need to represent e and p in a linear form. So we are going to rewrite the equation

r(\theta)

as
1
r(\theta)

=

1
p

-

e
p

\cos(\theta)

. Furthermore, one could fit for apsides by expanding

\cos(\theta)

with an extra parameter as

\cos(\theta-\theta0)=\cos(\theta)\cos(\theta0)+\sin(\theta)\sin(\theta0)

, which is linear in both

\cos(\theta)

and in the extra basis function

\sin(\theta)

, used to extra

\tan\theta0=\sin(\theta0)/\cos(\theta0)

. We use the original two-parameter form to represent our observational data as:

ATA\binom{x}{y}=ATb

where

x

is
1
p
and

y

is
e
p
and

A

is constructed by the first column being the coefficient of
1
p
and the second column being the coefficient of
e
p
and

b

is the values for the respective
1
r(\theta)
so

A=\begin{bmatrix}1&-0.731354\\1&-0.707107\\1&-0.615661\\1& 0.052336\\1&0.309017\\1&0.438371\end{bmatrix}

and

b=\begin{bmatrix}0.21220\\ 0.21958\\ 0.24741\\ 0.45071\\ 0.52883\\ 0.56820\end{bmatrix}.

On solving we get

\binom{x}{y}=\binom{0.43478}{0.30435}

so

p=1
x

=2.3000

and

e=py=0.70001

See also

Further reading

Notes and References

  1. Web site: 2022-03-01 . The Origins of Ordinary Least Squares Assumptions . 2024-05-16 . Feature Column . en-US.
  2. Web site: What is a complete list of the usual assumptions for linear regression? . 2022-09-28 . Cross Validated . en.
  3. Book: Goldberger, Arthur S. . Arthur Goldberger . Classical Linear Regression . Econometric Theory . New York . John Wiley & Sons . 1964 . 0-471-31101-4 . 158 . https://books.google.com/books?id=KZq5AAAAIAAJ&pg=PA156 .
  4. Book: Hayashi, Fumio . Fumio Hayashi . Econometrics . Princeton University Press . 2000 . 15 .
  5. Book: Adjustment Computations: Spatial Data Analysis. 9780471697282. Ghilani. Charles D.. Paul r. Wolf. Ph. D.. 12 June 2006.
  6. Book: GNSS – Global Navigation Satellite Systems: GPS, GLONASS, Galileo, and more. 9783211730171. Hofmann-Wellenhof. Bernhard. Lichtenegger. Herbert. Wasle. Elmar. 20 November 2007.
  7. Book: GPS: Theory, Algorithms and Applications. 9783540727156. Xu. Guochang. 5 October 2007.
  8. https://cran.r-project.org/doc/contrib/Faraway-PRA.pdf Julian Faraway (2000), Practical Regression and Anova using R
  9. Book: Kenney . J. . Keeping . E. S. . 1963 . Mathematics of Statistics . van Nostrand . 187 .
  10. Book: Zwillinger, D. . 1995 . Standard Mathematical Tables and Formulae . Chapman&Hall/CRC . 0-8493-2479-3 . 626 .
  11. Web site: Akbarzadeh. Vahab. Line Estimation. 7 May 2014 .
  12. Williams. M. N. Grajales. C. A. G. Kurkiewicz. D. Assumptions of multiple regression: Correcting two misconceptions. Practical Assessment, Research & Evaluation. 2013. 18. 11.
  13. Web site: Memento on EViews Output . 28 December 2020.
  14. Book: Amemiya, Takeshi . Takeshi Amemiya . Advanced Econometrics . registration . Harvard University Press . 1985 . 13 . 9780674005600 .
  15. Book: Rao, C. R. . C. R. Rao . Linear Statistical Inference and its Applications . New York . J. Wiley & Sons . 1973 . Second . 319 . 0-471-70823-2 .
  16. Book: Davidson . Russell . MacKinnon . James G. . Estimation and Inference in Econometrics . New York . Oxford University Press . 1993 . 0-19-506011-3 . 33 .
  17. Book: Burnham , Kenneth P. . 2nd . Springer . 0-387-95364-7 . David Anderson . Model Selection and Multi-Model Inference . 2002 . registration .