Skip to content

Tuorui "v1ncent19" Peng

En voyage dans l'espace de Hilbert.

Mathematics & Statistics3 min readEnglish

Residuals for Influential Diagnosis in Linear Regression

In linear regression, influential diagnosis is important to obtain better model fit and performance. Usually such diagnosis is based on residuals. Here are some important residuals that help locate influentials.

A point is called a influential if it violate the model + could (potentially) influence the estimator. The former is called outlier, the latter is called leverage.

Recap: Linear regression

For linear model (with intercept)

Y=Xn×(p+1)β(p+1)×1+ε,εN(0,σ2I)\begin{align} Y=\mathop{X}\limits_{n\times (p+1)} \mathop{\beta }\limits_{(p+1)\times 1} +\varepsilon ,\quad \varepsilon \sim N(0,\sigma ^2I) \end{align}

the OLS regression result:

Y^=X(XX)1XY:=HYH:=X(XX)1X=Y^Yβ^=(XX)1XYN(β,σ2(XX)1)e=Y^Y=(IH)YN(0,σ2(IH))σ^2=eenp1=Y(IH)Ynp1(np1)σ^2σ2χnp12\begin{align} \hat{Y}=&X(X'X)^{-1}X'Y:=HY\\ H:=&X(X'X)^{-1}X'=\dfrac{\partial^{} \hat{Y}}{\partial Y^{}}\\ \hat{\beta }=&(X'X)^{-1}X'Y\sim N(\beta ,\sigma ^2(X'X)^{-1})\\ e=&\hat{Y}-Y=(I-H)Y\sim N(0,\sigma ^2(I-H))\\ \hat{\sigma }^2=&\dfrac{e'e}{n-p-1}=\dfrac{Y'(I-H)Y}{n-p-1}\\ &\dfrac{(n-p-1)\hat{\sigma }^2}{\sigma ^2}\sim \chi^2_{n-p-1} \end{align}

Residuals

Self-sensitivity hiih_{ii} for Leverage Point

Self-sensitivity hiih_{ii} is the weight of data point in estimating Y^\hat{Y}. hiih_{ii} are the diagonal elements of hat matrix HH.

hii:=Y^Yii=Xi(XX)1Xi=Hii\begin{align} h_{ii}:=\dfrac{\partial^{} \hat{Y}}{\partial Y^{}}\Bigg|_{ii}=X_i'(X'X)^{-1}X_i=H_{ii} \end{align}

Comment: In linear regreesion, the design matrix XX is considered without randomness. Then the change in YY would results in change of β^\hat{\beta }, and finally result in change of Y^\hat{Y}. This is a measure of "how a data point is potentially capable of influencing estimation" -- Leverage.

Standardized Residual esdie_{\mathrm{sd}i} for Outlier

Standardized residual is just a normalization to σ2=1\sigma ^2=1

esdi=eiσei=eiσ1hiiN(0,1)\begin{align} e_{\mathrm{sd}i}=\dfrac{e_i}{\sigma _{e_i}}=\dfrac{e_i}{\sigma \sqrt{1-h_{ii}}}\sim N(0,1) \end{align}

Internally Studentized Residual rir_i

(Internally) Studentized residual is obtained by replacing σ\sigma into σ^\hat{\sigma } in standardized residual

ri=eiσ^1hiitnp1\begin{align} r_i=\dfrac{e_i}{\hat{\sigma }\sqrt{1-h_{ii}}}\sim t_{n-p-1} \end{align}

Deleted Residual did_i for Leverage

Recall that self-sensitivity reflected the influence when YiY_i changes. Here deleted residual focus on when YiY_i disappears. Denote Y^i(i)\hat{Y}_{i(\wedge i)} for estimator of YiY_i from the model without (Xi,Yi)(X_i,Y_i) involved (i.e. Y^i(i)\hat{Y}_{i(\wedge i)} is a predictor Y^i(i)=Xiβ^(i)\hat{Y}_{i(\wedge i)}=X_i'\hat{\beta }_{(\wedge i)}).

di=YiY^i(i)=ei1hii\begin{align} d_i=Y_i-\hat{Y}_{i(\wedge i)}\color{red}= \dfrac{e_i}{1-h_{ii}} \end{align}

Here's the proof for =\color{red}=:

  1. Sherman-Morrison lemma: (A+B)1=A111+tr(BA1)A1BA1(A+B)^{-1}=A^{-1}-\dfrac{1}{1+tr(BA^{-1})}A^{-1}BA^{-1} , where rank(B)=1\mathrm{rank}(B)=1. Denote B=uvB=uv', then:

    (A+B)1(A+B)=I+A1BA1B+A1BA1B1+tr(BA1)=I+A1BA1uv+A1u(vA1u)v1+tr(BA1=I+A1BA1uv(1+tr(uvA1))1+tr(BA1=I\begin{align} (A+B)^{-1}(A+B)=&I+A^{-1}B-\dfrac{A^{-1}B+A^{-1}BA^{-1}B}{1+tr(BA^{-1})}\\ =&I+A^{-1}B-\dfrac{A^{-1}uv'+A^{-1}u (v'A^{-1}u)v' }{1+tr(BA^{-1}}\\ =&I+A^{-1}B-\dfrac{A^{-1}uv'(1+tr(uv'A^{-1})) }{1+tr(BA^{-1}}\\ =&I \end{align}
  2. To solve β^(i)=(X(i)X(i))1X(i)\hat{\beta }_{(\wedge i)}=\left(X_{(\wedge i)}'X_{(\wedge i)}\right)^{-1}X'_{(\wedge i)}, here we denote XiX_i as a row vector, i.e.Xi=(1,Xi1,Xi2,,Xip)X_i=(1,X_{i1},X_{i2},\ldots,X_{ip}). Using the above lemma:

    (X(i)X(i))1=(XXXiXi)1=(XX)1+11tr[XiXi(XX)1](XX)1XiXi(XX)1=(XX)1+11hii(XX)1XiXi(XX)1X(i)Y(i)=XYXiYi\begin{align} (X_{(\wedge i)}'X_{(\wedge i)})^{-1}=&(X'X-X_i'X_i)^{-1}\\ =&(X'X)^{-1}+\dfrac{1}{1-tr[X_i'X_i(X'X)^{-1}]}(X'X)^{-1}X_i'X_i(X'X)^{-1}\\ =&(X'X)^{-1}+\dfrac{1}{1-h_{ii}}(X'X)^{-1}X_i'X_i(X'X)^{-1}\\ X_{(\wedge i)}Y_{(\wedge i)}=&X'Y-X_i'Y_i \end{align}

    then calaulate β^(i)\hat{\beta }_{(\wedge i)}:

    β^(i)=(X(i)X(i))1X(i)Y(i)=[(XX)1+(XX)1XiXi(XX)11hii](XYXiYi)=β^+(XX)1XiXi(XX)1XY1hii(XX)1XiYi(XX)1XiXi(XX)1XiYi1hii=β^+(XX)1XiY^i1hii(XX)1XiYi(1hii)1hii(XX)1XiYi1hiihii=β^+(XX)1Xi1hii(Y^iYi)\begin{align} \hat{\beta }_{(\wedge i)}=&(X_{(\wedge i)}'X_{(\wedge i)})^{-1}X_{(\wedge i)}'Y_{(\wedge i)}\notag \\ =&\left[(X'X)^{-1}+\dfrac{(X'X)^{-1}X_i'X_i(X'X)^{-1}}{1-h_{ii}}\right]\left(X'Y-X_i'Y_i\right)\notag\\ =&\hat{\beta }+\dfrac{(X'X)^{-1}X_i'{X_i(X'X)^{-1}X'Y}}{1-h_{ii}}-(X'X)^{-1}X_i'Y_i-\dfrac{(X'X)^{-1}X_i'{X_i(X'X)^{-1}X_i'}Y_i}{1-h_{ii}}\notag\\ =&\hat{\beta }+\dfrac{(X'X)^{-1}X_i'{\hat{Y}_i}}{1-h_{ii}}-\dfrac{(X'X)^{-1}X_i'Y_i(1-h_{ii})}{1-h_{ii}}-\dfrac{(X'X)^{-1}X_i'Y_i}{1-h_{ii}}{h_{ii}}\notag\\ =&\hat{\beta }+\dfrac{(X'X)^{-1}X_i'}{1-h_{ii}}(\hat{Y}_i-Y_i) \end{align}
  3. Then

    YiY^i(i)=YiY^i+Y^iY^i(i)=ei+Xi(β^β^(i))=ei+Xi(XX)1Xiei1hii=ei1hii\begin{align} Y_i-\hat{Y}_{i(\wedge i)}=&Y_i-\hat{Y}_i+\hat{Y}_i-\hat{Y}_{i(\wedge i)}\\ =&e_i+X_i(\hat{\beta }-\hat{\beta }_{(\wedge i)})\\ =&e_i+X_i(X'X)^{-1}X_i'\dfrac{e_i}{1-h_{ii}}\\ =&\dfrac{e_i}{1-h_{ii}} \end{align}

Comment: the result indicates that

di:=YiY^i(i)=ei1hiiN(0,σ21hii)\begin{align} d_i:=Y_i-\hat{Y}_{i(\wedge i)}=\dfrac{e_i}{1-h_{ii}}\sim N(0,\dfrac{\sigma ^2}{1-h_{ii}}) \end{align}

where σ2=σ^(i)2\sigma ^2=\hat{\sigma }_{(\wedge i)}^2 is estimated by the corresponding MSE\mathrm{MSE}

Externally Studentized Residual

In internally studentized residual, note that σ^2\hat{\sigma }^2 could be significantly influenced if YiY_i is an influential. To avoid the self-influence, eie_i is replaced by did_i, i.e.

ti:=dis(di)=eiσ^(i)1hiitnp2\begin{align} t_i:=\dfrac{d_i}{s(d_i)}=\dfrac{e_i}{\hat{\sigma }_{(\wedge i)}\sqrt{1-h_{ii}}}\sim t_{n-p-2} \end{align}

where the variance estimator is given by

(np2)σ^(i)2:=(np2)σ^2e(i)e(i)=(Y(i)X(i)β(i))(Y(i)X(i)β(i))=(eeei2)+2ei1hiihii(Y^iYi)+ei21hiihii=eeei21hii=(np1)σ^2ei21hii\begin{align} (n-p-2)\hat{\sigma }^2_{(\wedge i)}:=&(n-p-2)\hat{\sigma }^2 {e'_{(\wedge i)}e_{(\wedge i)}}{}\\ =&{(Y_{(\wedge i)}-X_{(\wedge i)}\beta _{(\wedge i)})'(Y_{(\wedge i)}-X_{(\wedge i)}\beta _{(\wedge i)})}\\ =&(e'e-e_i^2)+\dfrac{2e_i}{1-h_{ii}}h_{ii}(\hat{Y}_i-Y_i)+\dfrac{e_i^2}{1-h_{ii}}h_{ii} \\ =&e'e-\dfrac{e_i^2}{1-h_{ii}}\\ =&(n-p-1)\hat{\sigma }^2-\dfrac{e_i^2}{1-h_{ii}} \end{align}

thus externally studentized residual tit_i could also be expressed by rir_i as:

ti=eiσ^(i)1hii=eiσ^1hii(σ^σ^(i))1/2=ri(np2np1ri2)1/2<ri\begin{align} t_i=&\dfrac{e_i}{\hat{\sigma }_{(\wedge i)}\sqrt{1-h_{ii}}}\\ =&\dfrac{e_i}{\hat{\sigma }\sqrt{1-h_{ii}}}\left(\dfrac{\hat{\sigma }}{\hat{\sigma }_{(\wedge i)}}\right)^{1/2}\\ =&r_i\left(\dfrac{n-p-2}{n-p-1-r_i^2}\right)^{1/2}<r_i \end{align}