Multiple Linear Regression
Set Up
The model
Y = X β + ε Y=X\beta+\varepsilon
Y = X β + ε
where ε ∼ N ( 0 , σ 2 I n ) ⟹ Y ∼ N ( X β , σ 2 I n ) \varepsilon\sim N(\boldsymbol{0},\sigma^{2}I_{n})\implies Y\sim N(X\beta,\sigma^{2}I_{n}) ε ∼ N ( 0 , σ 2 I n ) ⟹ Y ∼ N ( X β , σ 2 I n ) . Here we see X X X as a fixed matrix or we condition on X X X (the whole matrix).
Suppose X n × p X_{n\times p} X n × p has full column rank.
OLS estimator for β \beta β is
b = ( X T X ) − 1 X T Y b=(X^TX)^{-1}X^TY
b = ( X T X ) − 1 X T Y
Projection matrix
H = X ( X T X ) − 1 X T H=X(X^TX)^{-1}X^T
H = X ( X T X ) − 1 X T
Fitted value
Y ^ = H Y = X b \hat{Y}=HY=Xb
Y ^ = H Y = X b
Residual
e = Y − Y ^ = ( I − H ) Y e=Y-\hat{Y}=(I-H)Y
e = Y − Y ^ = ( I − H ) Y
Here are some properties:
e T Y ^ = 0 e^T\hat{Y}=0 e T Y ^ = 0 T r ( H ) = p \mathrm{Tr}(H)=p Tr ( H ) = p .
Estimation of σ 2 \sigma^{2} σ 2
M S E = S S E n − p = e T e n − p MSE=\frac{SSE}{n-p}=\frac{e^Te}{n-p}
M S E = n − p S S E = n − p e T e
M S E MSE M S E is valid for estimating σ 2 \sigma^{2} σ 2 because
E [ M S E ] = 1 n − p E [ Y T ( I − H ) Y ] = σ 2 \mathbb{E}[MSE]=\frac{1}{n-p}\mathbb{E}[Y^T(I-H)Y]=\sigma^{2}
E [ M S E ] = n − p 1 E [ Y T ( I − H ) Y ] = σ 2
Let X X X be a random vector with E X = μ , C o v ( X ) = Σ \mathbb{E}X=\mu,\mathrm{Cov}(X)=\Sigma E X = μ , Cov ( X ) = Σ , then
E [ X T A X ] = T r ( A Σ ) + μ T A μ \mathbb{E}[X^TAX]=\mathrm{Tr}(A\Sigma)+\mu^TA\mu E [ X T A X ] = Tr ( A Σ ) + μ T A μ
The one-dimension version:
E [ a X 2 ] = a V [ X ] + a E 2 [ X ] \mathbb{E}[aX^{2}]=a\mathbb{V}[X]+a\mathbb{E}^{2}[X] E [ a X 2 ] = a V [ X ] + a E 2 [ X ]
▶
The proof (the trace trick)
Let C o v ( X ) = Σ , E [ X ] = μ \mathrm{Cov}(X)=\Sigma, \mathbb{E}[X]=\mu Cov ( X ) = Σ , E [ X ] = μ
E [ X T A X ] = T r [ ( E [ X T A X ] ) ] = E [ T r ( X T A X ) ] = E [ T r ( A X X T ) ] = T r [ A E ( X X T ) ] = T r [ A ( Σ + μ μ T ) ] = T r ( A Σ ) + μ T A μ \begin{align} \mathbb{E}[X^TAX] & = \mathrm{Tr}[(\mathbb{E}[X^TAX])] \\ & = \mathbb{E}[\mathrm{Tr}(X^TAX)] \\ & = \mathbb{E}[\mathrm{Tr}(AXX^T)] \\ & = \mathrm{Tr}[A\mathbb{E}(XX^T)] \\ & = \mathrm{Tr}[A(\Sigma+\mu \mu^T)] \\ & = \mathrm{Tr}(A\Sigma)+\mu^TA\mu \end{align} E [ X T A X ] = Tr [( E [ X T A X ])] = E [ Tr ( X T A X )] = E [ Tr ( A X X T )] = Tr [ A E ( X X T )] = Tr [ A ( Σ + μ μ T )] = Tr ( A Σ ) + μ T A μ
Sampling Distribution of b b b
Recall that
Y ∼ N ( X β , σ 2 I ) , b = ( X T X ) − 1 X T Y Y\sim N(X\beta,\sigma^{2}I),\ b=(X^TX)^{-1}X^TY
Y ∼ N ( X β , σ 2 I ) , b = ( X T X ) − 1 X T Y
So
b ∼ N ( β , σ 2 ( X T X ) − 1 ) b\sim N\left(\beta,\sigma^{2}(X^TX)^{-1}\right)
b ∼ N ( β , σ 2 ( X T X ) − 1 )
Replace σ 2 \sigma^{2} σ 2 with s 2 = M S E s^{2}=MSE s 2 = M S E to get the estimated covariance matrix.
Gauss-Markov Theorem
Under Gauss-Markov assumptions:
Linearity : the parameters are themselves linear Randomness : the data must have been randomly sampled from the population Non-Collinearity : the regressors aren’t perfectly correlated with each other Exogeneity : the regressors aren't correlated with the error term, E [ ε ∣ X ] = 0 \mathbb{E}[\varepsilon\mid X]=0 E [ ε ∣ X ] = 0 . (给定向量还是给定整个设计矩阵?) Homoscedasticity : no matter what the values of the regressors might be, the error of the variance is constant. the OLS estimate for regression coefficients gives you the best linear unbiased estimate (BLUE ) possible.
The Leverage
On one hand
H T = H = H 2 ⟹ h i i = e i T H e i = e i T H T H e i ≥ 0 H^T=H=H^{2}\implies h_{ii}=e_{i}^THe_{i}=e_{i}^TH^THe_{i}\geq 0
H T = H = H 2 ⟹ h ii = e i T H e i = e i T H T H e i ≥ 0
On the other hand,
e i T H e i = h i i = e i T H 2 e i = h i i 2 + ∑ i ≠ j h i j 2 ⟹ h i i ≥ h i i 2 ⟹ h i i ≤ 1 e_{i}^THe_{i}=h_{ii}=e_{i}^TH^{2}e_{i}=h_{ii}^{2}+\sum _{i\ne j}h_{ij}^{2}\implies h_{ii}\geq h_{ii}^{2}\implies h_{ii}\leq 1
e i T H e i = h ii = e i T H 2 e i = h ii 2 + i = j ∑ h ij 2 ⟹ h ii ≥ h ii 2 ⟹ h ii ≤ 1
In conclusion we have
h i i ∈ [ 0 , 1 ] h_{ii}\in [0,1]
h ii ∈ [ 0 , 1 ]
Don't forget that
h i i = ∂ Y ^ i ∂ Y i = ∂ ∑ j = 1 n h i j Y j ∂ Y i h_{ii}=\frac{ \partial \hat{Y}_{i} }{ \partial Y_{i} } = \frac{ \partial \sum_{j=1}^{n} h_{ij}Y_{j} }{ \partial Y_{i} }
h ii = ∂ Y i ∂ Y ^ i = ∂ Y i ∂ ∑ j = 1 n h ij Y j
Recall that here we say the leverage describes the distance of X i X_{i} X i from the center X ˉ \bar{X} X ˉ . Now we extend this concept to higher dimension.
The overall principle is to adjust the spread of each direction .
Let ( 1 , x i T ) (1, x_{i}^T) ( 1 , x i T ) be the i i i -th row of X X X and let x ˉ = 1 n ∑ x i \bar{x}=\frac{1}{n}\sum x_{i} x ˉ = n 1 ∑ x i . Here we define the distance of x i x_{i} x i from the center x ˉ \bar{x} x ˉ :
D ( x i , x ˉ ) = ( x i − x ˉ ) T Σ − 1 ( x − x ˉ ) D(x_{i},\bar{x})=\sqrt{(x_{i}-\bar{x})^T\Sigma^{-1}(x-\bar{x})}
D ( x i , x ˉ ) = ( x i − x ˉ ) T Σ − 1 ( x − x ˉ )
where Σ \Sigma Σ is the sample covariance matrix. Can show that
h i i = 1 n + D 2 ( x i , x ˉ ) n − 1 h_{ii}=\frac1n+\frac{D^2(x_{i},\bar{x})}{n-1}
h ii = n 1 + n − 1 D 2 ( x i , x ˉ )
This distance measure is known as Mahalanobis Distance .
Let X = [ 1 Z ] X=[\boldsymbol{1}\ Z] X = [ 1 Z ] , and Z c = Z − 1 n 1 1 T Z = ( I − J ) Z Z_{c}=Z-\frac{1}{n}\boldsymbol{1}\boldsymbol{1}^TZ=(I-J)Z Z c = Z − n 1 1 1 T Z = ( I − J ) Z (centralize it). Then
Σ = 1 n − 1 Z c T Z c = 1 n − 1 Z T ( I − J ) Z \Sigma=\frac{1}{n-1}Z_{c}^TZ_{c}=\frac{1}{n-1}Z^T(I-J)Z Σ = n − 1 1 Z c T Z c = n − 1 1 Z T ( I − J ) Z
We hope to find the relationship between the diagonal elements of
Z Σ − 1 Z T and H Z\Sigma^{-1}Z^T\ \text{and}\ H Z Σ − 1 Z T and H
Expand H H H as
[ 1 Z ] ( [ 1 Z ] T [ 1 Z ] ) − 1 [ 1 Z ] T = [ 1 Z ] [ n 1 T Z Z T 1 Z T Z ] − 1 [ 1 Z ] T [1\ Z]\left( [1\ Z]^T[1\ Z] \right) ^{-1}[1\ Z]^T= [1\ Z] \begin{bmatrix} n & \boldsymbol{1}^TZ \\ Z^T\boldsymbol{1} & Z^TZ \end{bmatrix}^{-1} [1\ Z]^T [ 1 Z ] ( [ 1 Z ] T [ 1 Z ] ) − 1 [ 1 Z ] T = [ 1 Z ] [ n Z T 1 1 T Z Z T Z ] − 1 [ 1 Z ] T
Recall the knowledge of Shur complement . Shur complement of n n n is
Z T Z − ( Z T 1 ) n − 1 ( 1 T Z ) = Z T ( I − J ) Z = : S Z^TZ-(Z^T\boldsymbol{1})n^{-1}(\boldsymbol{1}^TZ)=Z^T(I-J)Z=:S Z T Z − ( Z T 1 ) n − 1 ( 1 T Z ) = Z T ( I − J ) Z =: S
it is reversible iff 1 ∉ R ( Z ) \boldsymbol{1}\not\in \mathcal{R}(Z) 1 ∈ R ( Z ) , which is guaranteed. So
[ n 1 T Z Z T 1 Z T Z ] − 1 = [ 1 n + z ˉ T S − 1 z ˉ − z ˉ T S − 1 − S − 1 z ˉ S − 1 ] \begin{bmatrix} n & \boldsymbol{1}^TZ \\ Z^T\boldsymbol{1} & Z^TZ \end{bmatrix}^{-1} =\begin{bmatrix} \frac1n+\bar z^TS^{-1}\bar z&-\bar z^TS^{-1}\\ -S^{-1}\bar z&S^{-1} \end{bmatrix} [ n Z T 1 1 T Z Z T Z ] − 1 = [ n 1 + z ˉ T S − 1 z ˉ − S − 1 z ˉ − z ˉ T S − 1 S − 1 ]
therefore
h i i = [ 1 z i T ] [ 1 n + z ˉ T S − 1 z ˉ − z ˉ T S − 1 − S − 1 z ˉ S − 1 ] [ 1 z i ] = 1 n + ( z i − z ˉ ) T S − 1 ( z i − z ˉ ) h_{ii}= \begin{bmatrix} 1 & z_{i}^T \end{bmatrix} \begin{bmatrix} \frac1n+\bar z^TS^{-1}\bar z&-\bar z^TS^{-1}\\ -S^{-1}\bar z&S^{-1} \end{bmatrix} \begin{bmatrix} 1 \\ z_{i} \end{bmatrix} = \frac{1}{n}+(z_{i}-\bar{z})^TS^{-1}(z_{i}-\bar{z}) h ii = [ 1 z i T ] [ n 1 + z ˉ T S − 1 z ˉ − S − 1 z ˉ − z ˉ T S − 1 S − 1 ] [ 1 z i ] = n 1 + ( z i − z ˉ ) T S − 1 ( z i − z ˉ )
Note that S − 1 = Σ − 1 / ( n − 1 ) S^{-1}=\Sigma^{-1}/(n-1) S − 1 = Σ − 1 / ( n − 1 ) , so
h i i = 1 n + D 2 ( z i , z ˉ ) n − 1 h_{ii}=\frac{1}{n}+\frac{D^{2}(z_{i},\bar{z})}{n-1} h ii = n 1 + n − 1 D 2 ( z i , z ˉ )
Covariance Matrix of e e e
C o v ( e ) = C o v ( ( I − H ) Y ) = σ 2 ( I − H ) \mathrm{Cov}(e)=\mathrm{Cov}((I-H)Y)=\sigma^{2}(I-H)
Cov ( e ) = Cov (( I − H ) Y ) = σ 2 ( I − H )
so
V a r ( e i ) = σ 2 ( 1 − h i i ) C o v ( e i , e j ) = − σ 2 h i j \begin{align}
\mathrm{Var}(e_{i}) & =\sigma^{2}(1-h_{ii}) \\
\mathrm{Cov}(e_{i},e_{j}) & =-\sigma^{2}h_{ij}
\end{align}
Var ( e i ) Cov ( e i , e j ) = σ 2 ( 1 − h ii ) = − σ 2 h ij
Think a bit deeper: h i i h_{ii} h ii large ⟹ \implies ⟹ V a r ( e i ) \mathrm{Var}(e_{i}) Var ( e i ) closer to 0 ⟹ \implies ⟹ fitting is more stable.
Expected Mean Squares and ANOVA F-Test
Already showed that
E [ M S E ] = σ 2 \mathbb{E}[MSE]=\sigma^{2}
E [ M S E ] = σ 2
Let's see M S R = ∥ ( H − J ) Y ∥ 2 p − 1 MSR=\frac{\|(H-J)Y\|^{2}}{p-1} M S R = p − 1 ∥ ( H − J ) Y ∥ 2 .
E [ M S R ] = 1 p − 1 E [ Y T ( H − J ) Y ] = 1 p − 1 ( T r ( ( H − J ) σ 2 ) + ( X β ) T ( H − J ) ( X β ) ) = σ 2 + 1 p − 1 ( X β ) T ( H − J ) ( X β ) \begin{align}
\mathbb{E}[MSR] & = \frac{1}{p-1}\mathbb{E}[Y^T(H-J)Y] \\
& =\frac{1}{p-1}(\mathrm{Tr}((H-J)\sigma^{2})+(X\beta)^T(H-J)(X\beta)) \\
& = \sigma^{2}+\frac{1}{p-1}(X\beta)^T(H-J)(X\beta)
\end{align}
E [ M S R ] = p − 1 1 E [ Y T ( H − J ) Y ] = p − 1 1 ( Tr (( H − J ) σ 2 ) + ( X β ) T ( H − J ) ( X β )) = σ 2 + p − 1 1 ( X β ) T ( H − J ) ( X β )
Easy to see that
( X β ) T ( H − J ) ( X β ) = 0 ⟺ β 1 = β 2 = ⋯ = β p − 1 = 0 (X\beta)^T(H-J)(X\beta)=0 \iff \beta_{1}=\beta_{2}=\dots=\beta_{p-1}=0
( X β ) T ( H − J ) ( X β ) = 0 ⟺ β 1 = β 2 = ⋯ = β p − 1 = 0
Note that H − J H-J H − J is a projection matrix. So
( X β ) T ( H − J ) ( X β ) = 0 ⟺ ( H − J ) X β = 0 (X\beta)^T(H-J)(X\beta)=0 \iff (H-J)X\beta=0 ( X β ) T ( H − J ) ( X β ) = 0 ⟺ ( H − J ) X β = 0
Because X β ∈ R ( H ) X\beta\in \mathcal{R}(H) X β ∈ R ( H ) and R ( H ) = R ( H − J ) ⊕ R ( J ) \mathcal{R}(H)=\mathcal{R}(H-J)\oplus \mathcal{R}(J) R ( H ) = R ( H − J ) ⊕ R ( J ) , we have
( H − J ) X β = 0 ⟺ X β ∈ R ( J ) = s p a n ( 1 ) ⟺ β 2 = ⋯ = β p − 1 = 0 (H-J)X\beta=0 \iff X\beta\in \mathcal{R}(J)=\mathrm{span}(\boldsymbol{1}) \iff \beta_{2}=\dots=\beta_{p-1}=0 ( H − J ) X β = 0 ⟺ X β ∈ R ( J ) = span ( 1 ) ⟺ β 2 = ⋯ = β p − 1 = 0
This can be used to conduct the F-test:
H 0 : H_{0}: H 0 : β 1 = β 2 = ⋯ = β p − 1 = 0 \beta_{1}=\beta_{2}=\dots=\beta_{p-1}=0 β 1 = β 2 = ⋯ = β p − 1 = 0 .
H 1 : H_{1}: H 1 : β k ≠ 0 \beta_{k}\ne 0 β k = 0 for at least one k k k in 1 , 2 , … , p − 1 1,2,\dots,p-1 1 , 2 , … , p − 1 .
The F-statistic is
F = M S R M S E ∼ F p − 1 , n − p F=\frac{MSR}{MSE}\sim F_{p-1,n-p}
F = M S E M S R ∼ F p − 1 , n − p
Reject H 0 H_{0} H 0 if F F F is large enough.
R 2 R^{2} R 2 and Adjusted R 2 R^{2} R 2
R 2 = 1 − S S E S S T R^{2}=1-\frac{SSE}{SST}
R 2 = 1 − S S T S S E
But adding regressors can always decrease S S E SSE S S E . Penalty on adding regressors needed.
R a 2 = 1 − M S E M S T = 1 − n − 1 n − p ⋅ S S E S S T R_{a}^{2}=1-\frac{MSE}{MST}=1-\frac{n-1}{\color{red}n-p}\cdot\frac{SSE}{SST}
R a 2 = 1 − M S T M S E = 1 − n − p n − 1 ⋅ S S T S S E