Rahul Sharma (Editor)

Proofs involving ordinary least squares

Updated on
Edit
Like
Comment
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit

The purpose of this page is to provide supplementary materials for the ordinary least squares article, reducing the load of the main article with mathematics and improving its accessibility, while at the same time retaining the completeness of exposition.

Contents

Least squares estimator for β = b

Using matrix notation, the sum of squared residuals is given by

S ( b ) = ( y X b ) ( y X b )

Where denotes the matrix transpose.

Since this is a quadratic expression, the vector which gives the global minimum may be found via matrix calculus by differentiating with respect to the vector b (using denominator layout) and setting equal to zero:

0 = d S d b ( β ^ ) = d d b ( y y b X y y X b + b X X b ) | b = β ^ = 2 X y + 2 X X β ^

By assumption matrix X has full column rank, and therefore X'X is invertible and the least squares estimator for β is given by

β ^ = ( X X ) 1 X y

Unbiasedness and variance of β ^ {displaystyle {hat {eta }}}

Plug y =  + ε into the formula for β ^ and then use the Law of iterated expectation:

E [ β ^ ] = E [ ( X X ) 1 X ( X β + ε ) ] = β + E [ ( X X ) 1 X ε ] = β + E [ E [ ( X X ) 1 X ε | X ] ] = β + E [ ( X X ) 1 X E [ ε | X ] ] = β ,

where E[ε|X] = 0 by assumptions of the model.

For the variance, let σ 2 I denote the covariance matrix of ε . Then,

E [ ( β ^ β ) ( β ^ β ) T ] = E [ ( ( X X ) 1 X ε ) ( ( X X ) 1 X ε ) T ] = E [ ( X X ) 1 X ε ε X ( X X ) 1 ] = E [ ( X X ) 1 X σ 2 X ( X X ) 1 ] = E [ σ 2 ( X X ) 1 X X ( X X ) 1 ] = σ 2 ( X X ) 1 ,

where we used the fact that β ^ β is just an affine transformation of ε by the matrix ( X X ) 1 X ( see article on the multivariate normal distribution under the affine transformation section).

For a simple linear regression model, where β = [ β 0 , β 1 ] T ( β 0 is the y-intercept and β 1 is the slope), one obtains

σ 2 ( X X ) 1 = σ 2 ( x i x i ) 1 = σ 2 ( ( 1 , x i ) ( 1 , x i ) ) 1 = σ 2 ( ( 1 x i x i x i 2 ) ) 1 = σ 2 ( n x i x i x i 2 ) 1 = σ 2 1 n x i 2 ( x i ) 2 ( x i 2 x i x i n ) = σ 2 1 n i = 1 n ( x i x ¯ ) 2 ( x i 2 x i x i n ) Var ( β 1 ) = σ 2 i = 1 n ( x i x ¯ ) 2 .

Expected value of σ ^ 2 {displaystyle {hat {sigma }}^{2}}

First we will plug in the expression for y into the estimator, and use the fact that X'M = MX = 0 (matrix M projects onto the space orthogonal to X):

σ ^ 2 = 1 n y M y = 1 n ( X β + ε ) M ( X β + ε ) = 1 n ε M ε

Now we can recognize ε'Mε as a 1×1 matrix, such matrix is equal to its own trace. This is useful because by properties of trace operator, tr(AB)=tr(BA), and we can use this to separate disturbance ε from matrix M which is a function of regressors X:

E σ ^ 2 = 1 n E [ tr ( ε M ε ) ] = 1 n tr ( E [ M ε ε ] )

Using the Law of iterated expectation this can be written as

E σ ^ 2 = 1 n tr ( E [ M E [ ε ε | X ] ] ) = 1 n tr ( E [ σ 2 M I ] ) = 1 n σ 2 E [ tr M ]

Recall that M = I − P where P is the projection onto linear space spanned by columns of matrix X. By properties of a projection matrix, it has p = rank(X) eigenvalues equal to 1, and all other eigenvalues are equal to 0. Trace of a matrix is equal to the sum of its characteristic values, thus tr(P)=p, and tr(M) = n − p. Therefore,

E σ ^ 2 = n p n σ 2

Note: in the later section “Maximum likelihood” we show that under the additional assumption that errors are distributed normally, the estimator σ ^ 2 is proportional to a chi-squared distribution with n – p degrees of freedom, from which the formula for expected value would immediately follow. However the result we have shown in this section is valid regardless of the distribution of the errors, and thus has importance on its own.

Consistency and asymptotic normality of β ^ {displaystyle {hat {eta }}}

Estimator β ^ can be written as

β ^ = ( 1 n X X ) 1 1 n X y = β + ( 1 n X X ) 1 1 n X ε = β + ( 1 n i = 1 n x i x i ) 1 ( 1 n i = 1 n x i ε i )

We can use the law of large numbers to establish that

1 n i = 1 n x i x i   p   E [ x i x i ] = Q x x n , 1 n i = 1 n x i ε i   p   E [ x i ε i ] = 0

By Slutsky's theorem and continuous mapping theorem these results can be combined to establish consistency of estimator β ^ :

β ^   p   β + Q x x 1 0 = β

The central limit theorem tells us that

1 n i = 1 n x i ε i   d   N ( 0 , V ) , where V = Var [ x i ε i ] = E [ ε i 2 x i x i ] = E [ E [ ε i 2 x i ] x i x i ] = σ 2 Q x x n

Applying Slutsky's theorem again we'll have

n ( β ^ β ) = ( 1 n i = 1 n x i x i ) 1 ( 1 n i = 1 n x i ε i )   d   Q x x 1 n N ( 0 , σ 2 Q x x n ) = N ( 0 , σ 2 Q x x 1 n )

Maximum likelihood approach

Maximum likelihood estimation is a generic technique for estimating the unknown parameters in a statistical model by constructing a log-likelihood function corresponding to the joint distribution of the data, then maximizing this function over all possible parameter values. In order to apply this method, we have to make an assumption about the distribution of y given X so that the log-likelihood function can be constructed. The connection of maximum likelihood estimation to OLS arises when this distribution is modeled as a multivariate normal.

Specifically, assume that the errors ε have multivariate normal distribution with mean 0 and variance matrix σ2I. Then the distribution of y conditionally on X is

y | X     N ( X β , σ 2 I )

and the log-likelihood function of the data will be

L ( β , σ 2 | X ) = ln ( 1 ( 2 π ) n / 2 ( σ 2 ) n / 2 e 1 2 ( y X β ) ( σ 2 I ) 1 ( y X β ) ) = n 2 ln 2 π n 2 ln σ 2 1 2 σ 2 ( y X β ) ( y X β )

Differentiating this expression with respect to β and σ2 we'll find the ML estimates of these parameters:

L β = 1 2 σ 2 ( 2 X y + 2 X X β ) = 0 β ^ = ( X X ) 1 X y L σ 2 = n 2 1 σ 2 + 1 2 σ 4 ( y X β ) ( y X β ) = 0 σ ^ 2 = 1 n ( y X β ^ ) ( y X β ^ ) = 1 n S ( β ^ )

We can check that this is indeed a maximum by looking at the Hessian matrix of the log-likelihood function.

Finite-sample distribution

Since we have assumed in this section that the distribution of error terms is known to be normal, it becomes possible to derive the explicit expressions for the distributions of estimators β ^ and σ ^ 2 :

β ^ = ( X X ) 1 X y = ( X X ) 1 X ( X β + ε ) = β + ( X X ) 1 X N ( 0 , σ 2 I )

so that by the affine transformation properties of multivariate normal distribution

β ^ | X     N ( β , σ 2 ( X X ) 1 ) .

Similarly the distribution of σ ^ 2 follows from

σ ^ 2 = 1 n ( y X ( X X ) 1 X y ) ( y X ( X X ) 1 X y ) = 1 n ( M y ) M y = 1 n ( X β + ε ) M ( X β + ε ) = 1 n ε M ε ,

where M = I X ( X X ) 1 X is the symmetric projection matrix onto subspace orthogonal to X, and thus MX = X'M = 0. We have argued before that this matrix rank n – p, and thus by properties of chi-squared distribution,

n σ 2 σ ^ 2 | X = ( ε / σ ) M ( ε / σ )     χ n p 2

Moreover, the estimators β ^ and σ ^ 2 turn out to be independent (conditional on X), a fact which is fundamental for construction of the classical t- and F-tests. The independence can be easily seen from following: the estimator β ^ represents coefficients of vector decomposition of y ^ = X β ^ = P y = X β + P ε by the basis of columns of X, as such β ^ is a function of . At the same time, the estimator σ ^ 2 is a norm of vector divided by n, and thus this estimator is a function of . Now, random variables (, ) are jointly normal as a linear transformation of ε, and they are also uncorrelated because PM = 0. By properties of multivariate normal distribution, this means that and are independent, and therefore estimators β ^ and σ ^ 2 will be independent as well.

References

Proofs involving ordinary least squares Wikipedia