Proofs involving ordinary least squares
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.
Derivation of the normal equations
Define the [math]\displaystyle{ i }[/math]th residual to be
- [math]\displaystyle{ r_i= y_i - \sum_{j=1}^{n} X_{ij}\beta_j. }[/math]
Then the objective [math]\displaystyle{ S }[/math] can be rewritten
- [math]\displaystyle{ S = \sum_{i=1}^m r_i^2. }[/math]
Given that S is convex, it is minimized when its gradient vector is zero (This follows by definition: if the gradient vector is not zero, there is a direction in which we can move to minimize it further – see maxima and minima.) The elements of the gradient vector are the partial derivatives of S with respect to the parameters:
- [math]\displaystyle{ \frac{\partial S}{\partial \beta_j}=2\sum_{i = 1}^m r_i\frac{\partial r_i}{\partial \beta_j} \qquad (j=1,2,\dots, n). }[/math]
The derivatives are
- [math]\displaystyle{ \frac{\partial r_i}{\partial \beta_j}=-X_{ij}. }[/math]
Substitution of the expressions for the residuals and the derivatives into the gradient equations gives
- [math]\displaystyle{ \frac{\partial S}{\partial \beta_j} = 2\sum_{i=1}^{m} \left( y_i-\sum_{k=1}^{n} X_{ik}\beta_k \right) (-X_{ij})\qquad (j=1,2,\dots, n). }[/math]
Thus if [math]\displaystyle{ \widehat \beta }[/math] minimizes S, we have
- [math]\displaystyle{ 2\sum_{i=1}^{m} \left( y_i-\sum_{k=1}^{n} X_{ik}\widehat \beta_k \right) (-X_{ij}) = 0\qquad (j=1,2,\dots, n). }[/math]
Upon rearrangement, we obtain the normal equations:
- [math]\displaystyle{ \sum_{i=1}^{m}\sum_{k=1}^{n} X_{ij}X_{ik}\widehat \beta_k=\sum_{i=1}^{m} X_{ij}y_i\qquad (j=1,2,\dots, n). }[/math]
The normal equations are written in matrix notation as
- [math]\displaystyle{ (\mathbf X^\mathrm{T} \mathbf X) \widehat{\boldsymbol{\beta}} = \mathbf X^\mathrm{T} \mathbf y }[/math] (where XT is the matrix transpose of X).
The solution of the normal equations yields the vector [math]\displaystyle{ \widehat{\boldsymbol{\beta}} }[/math] of the optimal parameter values.
Derivation directly in terms of matrices
The normal equations can be derived directly from a matrix representation of the problem as follows. The objective is to minimize
- [math]\displaystyle{ S(\boldsymbol{\beta}) = \bigl\|\mathbf y - \mathbf X \boldsymbol \beta \bigr\|^2 = (\mathbf y-\mathbf X \boldsymbol \beta)^{\rm T}(\mathbf y-\mathbf X \boldsymbol \beta) = \mathbf y ^{\rm T} \mathbf y - \boldsymbol \beta ^{\rm T} \mathbf X ^{\rm T} \mathbf y - \mathbf y ^{\rm T} \mathbf X \boldsymbol \beta + \boldsymbol \beta ^{\rm T} \mathbf X ^{\rm T} \mathbf X \boldsymbol \beta . }[/math]
Here [math]\displaystyle{ ( \boldsymbol \beta ^{\rm T} \mathbf X ^{\rm T} \mathbf y ) ^{\rm T} = \mathbf y ^{\rm T} \mathbf X \boldsymbol \beta }[/math] has the dimension 1x1 (the number of columns of [math]\displaystyle{ \mathbf y }[/math]), so it is a scalar and equal to its own transpose, hence [math]\displaystyle{ \boldsymbol \beta ^{\rm T} \mathbf X ^{\rm T} \mathbf y = \mathbf y ^{\rm T} \mathbf X \boldsymbol \beta }[/math] and the quantity to minimize becomes
- [math]\displaystyle{ S(\boldsymbol{\beta}) = \mathbf y ^{\rm T} \mathbf y - 2\boldsymbol \beta ^{\rm T} \mathbf X ^{\rm T} \mathbf y + \boldsymbol \beta ^{\rm T} \mathbf X ^{\rm T} \mathbf X \boldsymbol \beta . }[/math]
Differentiating this with respect to [math]\displaystyle{ \boldsymbol \beta }[/math] and equating to zero to satisfy the first-order conditions gives
- [math]\displaystyle{ - \mathbf X^{\rm T} \mathbf y+ (\mathbf X^{\rm T} \mathbf X ){\boldsymbol{\beta}} = 0, }[/math]
which is equivalent to the above-given normal equations. A sufficient condition for satisfaction of the second-order conditions for a minimum is that [math]\displaystyle{ \mathbf X }[/math] have full column rank, in which case [math]\displaystyle{ \mathbf X^{\rm T} \mathbf X }[/math] is positive definite.
Derivation without calculus
When [math]\displaystyle{ \mathbf X^{\rm T} \mathbf X }[/math] is positive definite, the formula for the minimizing value of [math]\displaystyle{ \boldsymbol \beta }[/math] can be derived without the use of derivatives. The quantity
- [math]\displaystyle{ S(\boldsymbol{\beta}) = \mathbf y ^{\rm T} \mathbf y - 2\boldsymbol \beta ^{\rm T} \mathbf X ^{\rm T} \mathbf y + \boldsymbol \beta ^{\rm T} \mathbf X ^{\rm T} \mathbf X \boldsymbol \beta }[/math]
can be written as
- [math]\displaystyle{ \langle \boldsymbol \beta, \boldsymbol \beta \rangle - 2\langle \boldsymbol \beta, (\mathbf X^{\rm T} \mathbf X)^{-1}\mathbf X ^{\rm T} \mathbf y \rangle + \langle(\mathbf X^{\rm T} \mathbf X)^{-1}\mathbf X ^{\rm T} \mathbf y,(\mathbf X^{\rm T} \mathbf X)^{-1}\mathbf X ^{\rm T} \mathbf y \rangle+ C, }[/math]
where [math]\displaystyle{ C }[/math] depends only on [math]\displaystyle{ \mathbf y }[/math] and [math]\displaystyle{ \mathbf X }[/math], and [math]\displaystyle{ \langle \cdot, \cdot \rangle }[/math] is the inner product defined by
- [math]\displaystyle{ \langle x, y \rangle = x ^{\rm T} (\mathbf X^{\rm T} \mathbf X) y. }[/math]
It follows that [math]\displaystyle{ S(\boldsymbol{\beta}) }[/math] is equal to
- [math]\displaystyle{ \langle \boldsymbol \beta - (\mathbf X^{\rm T} \mathbf X)^{-1}\mathbf X ^{\rm T} \mathbf y,\boldsymbol \beta - (\mathbf X^{\rm T} \mathbf X)^{-1}\mathbf X ^{\rm T} \mathbf y \rangle+ C }[/math]
and therefore minimized exactly when
- [math]\displaystyle{ \boldsymbol \beta - (\mathbf X^{\rm T} \mathbf X)^{-1}\mathbf X ^{\rm T} \mathbf y = 0. }[/math]
Generalization for complex equations
In general, the coefficients of the matrices [math]\displaystyle{ \mathbf {X}, \boldsymbol{\beta} }[/math] and [math]\displaystyle{ \mathbf{y} }[/math] can be complex. By using a Hermitian transpose instead of a simple transpose, it is possible to find a vector [math]\displaystyle{ \boldsymbol{\widehat{\beta}} }[/math] which minimizes [math]\displaystyle{ S(\boldsymbol{\beta}) }[/math], just as for the real matrix case. In order to get the normal equations we follow a similar path as in previous derivations:
- [math]\displaystyle{ \displaystyle S(\boldsymbol{\beta})=\langle \mathbf {y} -\mathbf{X} \boldsymbol{\beta},\mathbf {y} -\mathbf {X} \boldsymbol{\beta} \rangle = \langle \mathbf {y} ,\mathbf {y} \rangle - \overline{\langle \mathbf{X} \boldsymbol{\beta},\mathbf {y} \rangle}-{\overline {\langle \mathbf{y},\mathbf{X} \boldsymbol{\beta}\rangle}} + \langle \mathbf {X} \boldsymbol{\beta},\mathbf {X} \boldsymbol{\beta} \rangle =\mathbf {y}^{\rm T} \overline{\mathbf {y}}-\boldsymbol{\beta}^\dagger \mathbf{X}^\dagger \mathbf{y} -\mathbf{y}^\dagger \mathbf {X} \boldsymbol{\beta} + \boldsymbol{\beta}^{\rm T} \mathbf {X} ^{\rm {T}} \overline{\mathbf {X} } \overline{\boldsymbol{\beta}}, }[/math]
where [math]\displaystyle{ \dagger }[/math] stands for Hermitian transpose.
We should now take derivatives of [math]\displaystyle{ S(\boldsymbol{\beta}) }[/math] with respect to each of the coefficients [math]\displaystyle{ \beta_j }[/math], but first we separate real and imaginary parts to deal with the conjugate factors in above expression. For the [math]\displaystyle{ \beta_j }[/math] we have
- [math]\displaystyle{ \beta_j = \beta_j^R + i\beta_j^I }[/math]
and the derivatives change into
- [math]\displaystyle{ \frac {\partial S}{\partial \beta_j} = \frac {\partial S}{\partial \beta_j^R} \frac {\partial \beta_j^R}{\partial \beta_j} + \frac {\partial S}{\partial \beta_j^I} \frac {\partial \beta_j^I}{\partial \beta_j} = \frac {\partial S}{\partial \beta_j^R} - i \frac {\partial S}{\partial \beta_j^I} \quad (j=1,2,3,\ldots,n). }[/math]
After rewriting [math]\displaystyle{ S(\boldsymbol{\beta}) }[/math] in the summation form and writing [math]\displaystyle{ \beta_j }[/math] explicitly, we can calculate both partial derivatives with result:
- [math]\displaystyle{ \begin{align} \frac {\partial S}{\partial \beta_j^R} = {} & -\sum_{i=1}^m \Big(\overline {X}_{ij} y_i + \overline{y}_i X_{ij} \Big) + 2\sum_{i=1}^m X_{ij} \overline{X}_{ij} \beta_j^R + \sum_{i=1}^m \sum_{k\neq j}^n \Big( X_{ij} \overline{X}_{ik} \overline{\beta}_k + \beta_k X_{ik} \overline{X}_{ij} \Big), \\[8pt] & {} -i{\frac {\partial S}{\partial \beta_j^I}} = \sum_{i=1}^m \Big(\overline{X}_{ij} y_i - \overline {y}_i X_{ij}{\Big )} - 2i\sum_{i=1}^m X_{ij}\overline{X}_{ij} \beta_j^I + \sum_{i=1}^m \sum_{k\neq j}^n \Big( X_{ij} \overline{X}_{ik} \overline{\beta}_k - \beta_k X_{ik} \overline{X}_{ij} \Big), \end{align} }[/math]
which, after adding it together and comparing to zero (minimization condition for [math]\displaystyle{ \boldsymbol{\widehat{\beta}} }[/math]) yields
- [math]\displaystyle{ \sum_{i=1}^m X_{ij} \overline{y}_i = \sum_{i=1}^m \sum_{k=1}^n X_{ij} \overline{X}_{ik} \overline{\widehat{\beta}}_k \qquad (j=1,2,3,\ldots,n). }[/math]
In matrix form:
- [math]\displaystyle{ \textbf{X}^{\rm {T}} \overline{\textbf{y}} = \textbf{X}^{\rm T} \overline{\big( \textbf{X} \boldsymbol{\widehat{\beta}} \big)} \quad \text{ or }\quad \big (\textbf{X}^\dagger \textbf{X} \big) \boldsymbol{\widehat{\beta}} = \textbf{X}^\dagger \textbf{y}. }[/math]
Least squares estimator for β
Using matrix notation, the sum of squared residuals is given by
- [math]\displaystyle{ S(\beta) = (y-X\beta)^T(y-X\beta). }[/math]
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 [math]\displaystyle{ \beta }[/math] (using denominator layout) and setting equal to zero:
- [math]\displaystyle{ 0 = \frac{dS}{d\beta}(\widehat\beta) = \frac{d}{d\beta}\bigg(y^Ty - \beta^TX^Ty - y^TX\beta + \beta^TX^TX\beta\bigg)\bigg|_{\beta=\widehat\beta} = -2X^Ty + 2X^TX\widehat\beta }[/math]
By assumption matrix X has full column rank, and therefore XTX is invertible and the least squares estimator for β is given by
- [math]\displaystyle{ \widehat\beta = (X^TX)^{-1}X^Ty }[/math]
Unbiasedness and variance of [math]\displaystyle{ \widehat\beta }[/math]
Plug y = Xβ + ε into the formula for [math]\displaystyle{ \widehat\beta }[/math] and then use the law of total expectation:
- [math]\displaystyle{ \begin{align}\operatorname{E}[\,\widehat\beta] &= \operatorname{E}\Big[(X^TX)^{-1}X^T(X\beta+\varepsilon)\Big] \\ &= \beta + \operatorname{E}\Big[(X^TX)^{-1}X^T\varepsilon\Big] \\ &= \beta + \operatorname{E}\Big[\operatorname{E}\Big[(X^TX)^{-1}X^T\varepsilon \mid X \Big]\Big] \\ &= \beta + \operatorname{E}\Big[(X^TX)^{-1}X^T\operatorname{E}[\varepsilon\mid X]\Big] &= \beta, \end{align} }[/math]
where E[ε|X] = 0 by assumptions of the model. Since the expected value of [math]\displaystyle{ \widehat{\beta} }[/math] equals the parameter it estimates, [math]\displaystyle{ \beta }[/math], it is an unbiased estimator of [math]\displaystyle{ \beta }[/math].
For the variance, let the covariance matrix of [math]\displaystyle{ \varepsilon }[/math] be [math]\displaystyle{ \operatorname{E}[\,\varepsilon\varepsilon^T\,] = \sigma^2 I }[/math] (where [math]\displaystyle{ I }[/math] is the identity [math]\displaystyle{ m\,\times\,m }[/math] matrix). Then,
- [math]\displaystyle{ \begin{align} \operatorname{E}[\,(\widehat\beta - \beta)(\widehat\beta - \beta)^T] &= \operatorname{E}\Big[ ((X^TX)^{-1}X^T\varepsilon)((X^TX)^{-1}X^T\varepsilon)^T \Big] \\ &= \operatorname{E}\Big[ (X^TX)^{-1}X^T\varepsilon\varepsilon^TX(X^TX)^{-1} \Big] \\ &= \operatorname{E}\Big[ (X^TX)^{-1}X^T\sigma^2X(X^TX)^{-1} \Big] \\ &= \operatorname{E}\Big[ \sigma^2(X^TX)^{-1}X^TX(X^TX)^{-1} \Big] \\ &= \sigma^2 (X^TX)^{-1}, \end{align} }[/math]
where we used the fact that [math]\displaystyle{ \widehat{\beta} - \beta }[/math] is just an affine transformation of [math]\displaystyle{ \varepsilon }[/math] by the matrix [math]\displaystyle{ (X^TX)^{-1}X^T }[/math].
For a simple linear regression model, where [math]\displaystyle{ \beta = [\beta_0,\beta_1]^T }[/math] ([math]\displaystyle{ \beta_0 }[/math] is the y-intercept and [math]\displaystyle{ \beta_1 }[/math] is the slope), one obtains
- [math]\displaystyle{ \begin{align} \sigma^2 (X^TX)^{-1} &= \sigma^2 \left( \begin{pmatrix} 1&1& \cdots \\x_1&x_2& \cdots \end{pmatrix}\begin{pmatrix} 1& x_1\\1& x_2\\ \vdots & \vdots\,\,\, \end{pmatrix} \right)^{-1}\\[6pt] &= \sigma^2 \left(\sum_{i=1}^m \begin{pmatrix} 1& x_i\\x_i& x_i^2\end{pmatrix} \right)^{-1}\\[6pt] &= \sigma^2 \begin{pmatrix} m& \sum x_i\\\sum x_i& \sum x_i^2\end{pmatrix}^{-1}\\[6pt] &= \sigma^2 \cdot \frac{1}{m\sum x_i^2-(\sum x_i)^2}\begin{pmatrix} \sum x_i^2& -\sum x_i\\-\sum x_i& m\end{pmatrix}\\[6pt] &= \sigma^2 \cdot \frac{1}{m\sum{(x_i - \bar{x})^2}}\begin{pmatrix} \sum x_i^2& -\sum x_i\\-\sum x_i& m\end{pmatrix} \\[8pt] \operatorname{Var}(\widehat\beta_1) &= \frac{\sigma^2}{\sum_{i=1}^m (x_i - \bar{x})^2}. \end{align} }[/math]
Expected value and biasedness of [math]\displaystyle{ \widehat\sigma^{\,2} }[/math]
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):
- [math]\displaystyle{ \widehat\sigma^{\,2} = \tfrac{1}{n}y'My = \tfrac{1}{n} (X\beta+\varepsilon)'M(X\beta+\varepsilon) = \tfrac{1}{n} \varepsilon'M\varepsilon }[/math]
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:
- [math]\displaystyle{ \operatorname{E}\,\widehat\sigma^{\,2} = \tfrac{1}{n}\operatorname{E}\big[\operatorname{tr}(\varepsilon'M\varepsilon)\big] = \tfrac{1}{n}\operatorname{tr}\big(\operatorname{E}[M\varepsilon\varepsilon']\big) }[/math]
Using the Law of iterated expectation this can be written as
- [math]\displaystyle{ \operatorname{E}\,\widehat\sigma^{\,2} = \tfrac{1}{n}\operatorname{tr}\Big(\operatorname{E}\big[M\,\operatorname{E}[\varepsilon\varepsilon'|X]\big]\Big) = \tfrac{1}{n}\operatorname{tr}\big(\operatorname{E}[\sigma^2MI]\big) = \tfrac{1}{n}\sigma^2\operatorname{E}\big[ \operatorname{tr}\,M \big] }[/math]
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,
- [math]\displaystyle{ \operatorname{E}\,\widehat\sigma^{\,2} = \frac{n-p}{n} \sigma^2 }[/math]
Since the expected value of [math]\displaystyle{ \widehat\sigma^{\,2} }[/math] does not equal the parameter it estimates, [math]\displaystyle{ \sigma^{\,2} }[/math], it is a biased estimator of [math]\displaystyle{ \sigma^{\,2} }[/math]. Note in the later section “Maximum likelihood” we show that under the additional assumption that errors are distributed normally, the estimator [math]\displaystyle{ \widehat\sigma^{\,2} }[/math] 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 [math]\displaystyle{ \widehat\beta }[/math]
Estimator [math]\displaystyle{ \widehat\beta }[/math] can be written as
- [math]\displaystyle{ \widehat\beta = \big(\tfrac{1}{n}X'X\big)^{-1}\tfrac{1}{n}X'y = \beta + \big(\tfrac{1}{n}X'X\big)^{-1}\tfrac{1}{n} X'\varepsilon = \beta\; + \;\bigg(\frac{1}{n}\sum_{i=1}^n x_ix'_i\bigg)^{\!\!-1} \bigg(\frac{1}{n}\sum_{i=1}^n x_i\varepsilon_i\bigg) }[/math]
We can use the law of large numbers to establish that
- [math]\displaystyle{ \frac{1}{n}\sum_{i=1}^n x_ix'_i\ \xrightarrow{p}\ \operatorname{E}[x_ix_i']=\frac{Q_{xx}}{n}, \qquad \frac{1}{n}\sum_{i=1}^n x_i\varepsilon_i\ \xrightarrow{p}\ \operatorname{E}[x_i\varepsilon_i]=0 }[/math]
By Slutsky's theorem and continuous mapping theorem these results can be combined to establish consistency of estimator [math]\displaystyle{ \widehat\beta }[/math]:
- [math]\displaystyle{ \widehat\beta\ \xrightarrow{p}\ \beta + nQ_{xx}^{-1}\cdot 0 = \beta }[/math]
The central limit theorem tells us that
- [math]\displaystyle{ \frac{1}{\sqrt{n}}\sum_{i=1}^n x_i\varepsilon_i\ \xrightarrow{d}\ \mathcal{N}\big(0,\,V\big), }[/math] where [math]\displaystyle{ V = \operatorname{Var}[x_i\varepsilon_i] = \operatorname{E}[\,\varepsilon_i^2x_ix'_i\,] = \operatorname{E}\big[\,\operatorname{E}[\varepsilon_i^2\mid x_i]\;x_ix'_i\,\big] = \sigma^2 \frac{Q_{xx}}{n} }[/math]
Applying Slutsky's theorem again we'll have
- [math]\displaystyle{ \sqrt{n}(\widehat\beta-\beta) = \bigg(\frac{1}{n}\sum_{i=1}^n x_ix'_i\bigg)^{\!\!-1} \bigg(\frac{1}{\sqrt{n}}\sum_{i=1}^n x_i\varepsilon_i\bigg)\ \xrightarrow{d}\ Q_{xx}^{-1}n\cdot\mathcal{N}\big(0, \sigma^2\frac{Q_{xx}}{n}\big) = \mathcal{N}\big(0,\sigma^2Q_{xx}^{-1}n\big) }[/math]
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
- [math]\displaystyle{ y\mid X\ \sim\ \mathcal{N}(X\beta,\, \sigma^2I) }[/math]
and the log-likelihood function of the data will be
- [math]\displaystyle{ \begin{align} \mathcal{L}(\beta,\sigma^2\mid X) &= \ln\bigg( \frac{1}{(2\pi)^{n/2}(\sigma^2)^{n/2}}e^{ -\frac{1}{2}(y-X\beta)'(\sigma^2I)^{-1}(y-X\beta) } \bigg) \\[6pt] &= -\frac{n}{2}\ln 2\pi - \frac{n}{2}\ln\sigma^2 - \frac{1}{2\sigma^2}(y-X\beta)'(y-X\beta) \end{align} }[/math]
Differentiating this expression with respect to β and σ2 we'll find the ML estimates of these parameters:
- [math]\displaystyle{ \begin{align} \frac{\partial\mathcal{L}}{\partial\beta'} & = -\frac{1}{2\sigma^2}\Big(-2X'y + 2X'X\beta\Big)=0 \quad\Rightarrow\quad \widehat\beta = (X'X)^{-1}X'y \\[6pt] \frac{\partial\mathcal{L}}{\partial\sigma^2} & = -\frac{n}{2} \frac{1}{\sigma^2} + \frac{1}{2\sigma^4}(y-X\beta)'(y-X\beta)=0 \quad\Rightarrow\quad \widehat\sigma^{\,2} = \frac{1}{n} (y-X\widehat\beta)'(y-X\widehat\beta) = \frac{1}{n} S(\widehat\beta) \end{align} }[/math]
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 [math]\displaystyle{ \widehat\beta }[/math] and [math]\displaystyle{ \widehat\sigma^{\,2} }[/math]:
- [math]\displaystyle{ \widehat\beta = (X'X)^{-1}X'y = (X'X)^{-1}X'(X\beta+\varepsilon) = \beta + (X'X)^{-1}X'\mathcal{N}(0,\sigma^2I) }[/math]
so that by the affine transformation properties of multivariate normal distribution
- [math]\displaystyle{ \widehat\beta\mid X\ \sim\ \mathcal{N}(\beta,\, \sigma^2(X'X)^{-1}). }[/math]
Similarly the distribution of [math]\displaystyle{ \widehat\sigma^{\,2} }[/math] follows from
- [math]\displaystyle{ \begin{align} \widehat\sigma^{\,2} &= \tfrac{1}{n}(y-X(X'X)^{-1}X'y)'(y-X(X'X)^{-1}X'y) \\[5pt] &= \tfrac{1}{n}(My)'My \\[5pt] &=\tfrac{1}{n}(X\beta+\varepsilon)'M(X\beta+\varepsilon) \\[5pt] &= \tfrac{1}{n}\varepsilon'M\varepsilon, \end{align} }[/math]
where [math]\displaystyle{ M=I-X(X'X)^{-1}X' }[/math] 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,
- [math]\displaystyle{ \tfrac{n}{\sigma^2} \widehat\sigma^{\,2}\mid X = (\varepsilon/\sigma)'M(\varepsilon/\sigma)\ \sim\ \chi^2_{n-p} }[/math]
Moreover, the estimators [math]\displaystyle{ \widehat\beta }[/math] and [math]\displaystyle{ \widehat\sigma^{\,2} }[/math] 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 [math]\displaystyle{ \widehat\beta }[/math] represents coefficients of vector decomposition of [math]\displaystyle{ \widehat{y}=X\widehat\beta=Py=X\beta+P\varepsilon }[/math] by the basis of columns of X, as such [math]\displaystyle{ \widehat\beta }[/math] is a function of Pε. At the same time, the estimator [math]\displaystyle{ \widehat\sigma^{\,2} }[/math] is a norm of vector Mε divided by n, and thus this estimator is a function of Mε. Now, random variables (Pε, Mε) 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 Pε and Mε are independent, and therefore estimators [math]\displaystyle{ \widehat\beta }[/math] and [math]\displaystyle{ \widehat\sigma^{\,2} }[/math] will be independent as well.
Derivation of simple linear regression estimators
We look for [math]\displaystyle{ \widehat{\alpha} }[/math] and [math]\displaystyle{ \widehat{\beta} }[/math] that minimize the sum of squared errors (SSE):
- [math]\displaystyle{ \min_{\widehat{\alpha}, \widehat{\beta}} \,\operatorname{SSE}\left(\widehat{\alpha}, \widehat{\beta}\right) \equiv \min_{\widehat{\alpha}, \widehat{\beta}} \sum_{i=1}^n \left(y_i - \widehat{\alpha} - \widehat{\beta} x_i\right)^2 }[/math]
To find a minimum take partial derivatives with respect to [math]\displaystyle{ \widehat{\alpha} }[/math] and [math]\displaystyle{ \widehat{\beta} }[/math]
- [math]\displaystyle{ \begin{align} &\frac{\partial}{\partial\widehat{\alpha}} \left (\operatorname{SSE} \left(\widehat{\alpha}, \widehat{\beta}\right) \right ) = -2\sum_{i=1}^n \left(y_i - \widehat{\alpha} - \widehat{\beta}x_i\right) = 0 \\[4pt] \Rightarrow {} &\sum_{i=1}^n \left(y_i - \widehat{\alpha} - \widehat{\beta}x_i\right) = 0 \\[4pt] \Rightarrow {} &\sum_{i=1}^n y_i = \sum_{i=1}^n \widehat{\alpha} + \widehat{\beta}\sum_{i=1}^n x_i \\[4pt] \Rightarrow {} &\sum_{i=1}^n y_i = n\widehat{\alpha} + \widehat{\beta}\sum_{i=1}^n x_i \\[4pt] \Rightarrow {} &\frac{1}{n}\sum_{i=1}^n y_{i} = \widehat{\alpha} + \frac{1}{n} \widehat{\beta}\sum_{i=1}^n x_i \\[4pt] \Rightarrow {} &\bar{y} = \widehat{\alpha} + \widehat{\beta}\bar{x} \end{align} }[/math]
Before taking partial derivative with respect to [math]\displaystyle{ \widehat{\beta} }[/math], substitute the previous result for [math]\displaystyle{ \widehat{\alpha}. }[/math]
- [math]\displaystyle{ \min_{\widehat{\alpha}, \widehat{\beta}} \sum_{i=1}^n \left[y_i - \left(\bar{y} - \widehat{\beta} \bar{x}\right) - \widehat{\beta}x_{i}\right]^2 = \min_{\widehat{\alpha}, \widehat{\beta}} \sum_{i=1}^n \left[\left(y_i - \bar{y}\right) - \widehat{\beta}\left(x_i - \bar{x}\right) \right]^2 }[/math]
Now, take the derivative with respect to [math]\displaystyle{ \widehat{\beta} }[/math]:
- [math]\displaystyle{ \begin{align} &\frac{\partial}{\partial\widehat{\beta}} \left (\operatorname{SSE} \left(\widehat{\alpha}, \widehat{\beta}\right) \right )= -2\sum_{i=1}^n \left[\left(y_{i} - \bar{y}\right) - \widehat{\beta}\left(x_{i} - \bar{x}\right)\right]\left(x_{i}-\bar{x}\right) = 0 \\ \Rightarrow {} &\sum_{i=1}^n \left(y_i - \bar{y}\right)\left(x_i - \bar{x}\right) - \widehat{\beta}\sum_{i=1}^n \left(x_i - \bar{x}\right)^2 = 0 \\ \Rightarrow {} & \widehat{\beta} = \frac{\sum_{i=1}^n \left(y_{i} - \bar{y}\right)\left(x_i - \bar{x}\right)}{\sum_{i=1}^n \left(x_{i}-\bar{x}\right)^2} = \frac{\operatorname{Cov}(x, y)}{\operatorname{Var}(x)} \end{align} }[/math]
And finally substitute [math]\displaystyle{ \widehat{\beta} }[/math] to determine [math]\displaystyle{ \widehat{\alpha} }[/math]
- [math]\displaystyle{ \widehat{\alpha} = \bar{y} - \widehat{\beta}\bar{x} }[/math]
This article does not cite any external source. HandWiki requires at least one external source. See citing external sources. (2021) (Learn how and when to remove this template message) |
Original source: https://en.wikipedia.org/wiki/Proofs involving ordinary least squares.
Read more |