8 Multiple Linear Regression: Example & Inference

Example

EDA

Although YiY_{i} have different distributions thus the histogram of YiY_{i} cannot reflect anything, we don't want YiY_{i} at our hand to be skewed.

If skewness is presented, we should use transformations to make them distributed more symmetrically.

But... Think twice before transforming the data.

Refers to standardization of data: "What?! It's useless to me. I need the result expressed in mg/dL, not standard deviations. Don't you, statisticians, understand, that clinical parameters are meaningful along with the units? This is hopeless and I'm gonna throw this in the garbage right now."

Model Selection

In a nutshell:

  • When having gotten a model, see the pp-value of F-statistic.
  • When comparing models, look at the adjusted R2R^{2} or MSEMSE (they are equivalent).

* Why Significant Variables But Low R2R^{2} ?

Significance: Find a linear relationship (trend) between XX and YY.

Low R2R^{2}: Linear relationship cannot fit very well.

发现一个可靠的规律,不等于这个规律足以预测个体。(GPT-6.1-Sol)

Inference in MLR

Recall

  • b=(XTX)−1XTYb=(X^TX)^{-1}X^TY
  • Y^=HY, H=X(XTX)−1XT\hat{Y}=HY,\ H=X(X^TX)^{-1}X^T
  • e=(I−H)Ye=(I-H)Y
  • s2=eTen−p=MSEs^{2}=\dfrac{e^Te}{n-p}=MSE

The Fundamental Theorems

Lemma
Suppose X∼N(μ,I)X\sim N(\mu,I), AA is a projection matrix with rank rr, then

XTAX∼χr,μTAμ2X^TAX\sim \chi^{2}_{r,\mu^TA\mu}

The definition of the non-central chi-square distribution:

If X1,…,XkX_1,\ldots,X_k are independent normal random variables with means μi\mu_i and unit variances, then

∑i=1kXi2∼χk,∑i=1kμi22.\sum_{i=1}^k X_i^2\sim\chi^2_{k,\sum_{i=1}^k\mu_i^2}.

The key is to show that XTAXX^TAX can be expressed as the sum of squares of rr independent normal random variables.

Since AA is symmetric and idempotent, it admits an orthogonal decomposition

A=QΛQT,A=Q\Lambda Q^T,

where Λ=diag⁡(1,…,1,0,…,0)\Lambda=\operatorname{diag}(1,\ldots,1,0,\ldots,0), with rr ones.

Let Y=QTXY=Q^TX. Then the components of YY are independent, and

XTAX=∑i=1rYi2.X^TAX=\sum_{i=1}^rY_i^2.

The sum of squared means of the first rr components of YY is

μTQΛQTμ=μTAμ.\mu^TQ\Lambda Q^T\mu =\mu^TA\mu.

Therefore,

XTAX∼χr,μTAμ2.X^TAX\sim\chi^2_{r,\mu^TA\mu}.

Lemma
Suppose Ap×pA_{p \times p} is a symmetric and idempotent matrix, BB is a k×pk \times p matrix and Y∼Np(μ,Σ)Y\sim N_{p}(\mu,\Sigma). Then

BY⊥YTAY  ⟺  BΣA=OBY \perp Y^TAY \iff B\Sigma A=O

The core is to prove that BY⊥AYBY \perp AY. Because a linear transformation of a multivariate normal random vector is still a multivariate normal random vector,

[AYBY]=[AB]Y\begin{bmatrix} AY \\ BY \end{bmatrix}= \begin{bmatrix} A \\ B \end{bmatrix}Y

is MVN. Thus independency   ⟺  \iff irrelevance. And we have

Cov(BY,AY)=BΣAT=BΣA=O.\mathrm{Cov}(BY,AY)=B\Sigma A^T=B\Sigma A=O.

Therefore, BY⊥AYBY \perp AY.

With the two lemmas above, we have

Theorem
Suppose that Y∼Nn(Xβ,σ2I)Y\sim N_{n}(X\beta,\sigma^{2}I) where XX is a full rank n×pn\times p matrix, then

  • b∼Np(β,σ2(XTX)−1)b\sim N_{p}(\beta,\sigma^{2}(X^TX)^{-1}).
  • eTeσ2=(n−p)s2σ2∼χn−p2\dfrac{e^Te}{\sigma^{2}}=\dfrac{(n-p)s^{2}}{\sigma^{2}}\sim \chi^{2}_{n-p}.
  • b⊥s2b \perp s^{2}.

F-Test for Linear Relation

Hypothesis:

  • H0: β1=⋯=βp−1=0H_{0}:\ \beta_{1}=\dots=\beta_{p-1}=0
  • Ha: o.w.H_{a}:\ \mathrm{o.w.}

Test statistic:

F=MSRMSEF=\frac{MSR}{MSE}

(H−J)Y⊥(I−H)Y,YT(I−H)Yσ2∼χn−p2(H-J)Y \perp (I-H)Y, \frac{Y^T(I-H)Y}{\sigma^{2}}\sim \chi^{2}_{n-p}, and under H0H_{0} we have

YT(H−J)Yσ2=εT(H−J)εσ2∼χp−12\frac{Y^T(H-J)Y}{\sigma^{2}}= \frac{\varepsilon^T(H-J)\varepsilon}{\sigma^{2}} \sim \chi^{2}_{p-1}

So under H0H_{0},

F∼Fp−1,n−pF\sim F_{p-1,n-p}

Reject if FF is large enough.

tt-Test for Individual Coefficients

Hypothesis:

  • H0: βk=0H_{0}:\ \beta_{k}=0
  • Ha: o.w.H_{a}:\ \mathrm{o.w.}.

Test statistic:

t=bks(bk)t=\frac{b_{k}}{s(b_{k})}

We have

b∼N(β,σ2(XTX)−1)b\sim N\left( \beta,\sigma^{2}(X^TX)^{-1} \right)

Thus

bk∼N(βk,σ2[(XTX)−1]k,k)b_{k}\sim N\big(\beta_{k},\sigma^{2}[(X^TX)^{-1}]_{k,k}\big)

And because b⊥s2b \perp s^{2} and eTeσ2=(n−p)s2σ2∼χn−p2\frac{e^Te}{\sigma^{2}}=\frac{(n-p)s^{2}}{\sigma^{2}}\sim \chi^{2}_{n-p}, we have

t∼tn−pt\sim t_{n-p}

under H0H_{0}.

Reject if ∣t∣|t| is large enough.

* Another View

Use GLT (General Linear Test), the full model is

Y=Xβ+εY = X\beta+\varepsilon

the reduced model is

Y=X−kβ−k+εY=X_{-k}\beta_{-k}+\varepsilon

where X−kX_{-k} is obtained by removing the kk-th column of XX, and β−k\beta_{-k} is obtained by removing βk\beta_k from β\beta.

The general linear test statistic is

F=(SSER−SSEF)/(dfR−dfF)SSEF/dfFF=\frac{(SSE_R-SSE_F)/(df_{R}-df_{F})}{SSE_F/df_F}

and we know dfR=n−p+1,dfF=n−pdf_{R}=n-p+1,df_{F}=n-p, and

SSER−SSEFσ2=YT(… )Y∼χ12SSEFσ2∼χn−p2\begin{align} \frac{SSE_{R}-SSE_{F}}{\sigma^{2}}=Y^T(\dots) Y & \sim \chi^{2}_{1}\\ \\ \frac{SSE_F}{\sigma^{2}} & \sim \chi^{2}_{n-p} \end{align}

and they are independent. So F∼F1,n−pF\sim F_{1,n-p}.

Furthermore, it can be shown that

SSER−SSEF=bk2[(XTX)−1]k,kSSE_R-SSE_F =\frac{b_k^2}{[(X^TX)^{-1}]_{k,k}}

So F=t2F=t^{2}.

The tt-test is equivalent to a specific F-test, so the tt-test examines the significance of a variable when it is added last to the model.

This will be discussed more in next lecture.

Inference about Prediction

Prediction of the Mean

We got Xh=[1Xh1…Xh,p−1]X_{h}=\begin{bmatrix}1 & X_{h 1} & \dots & X_{h,p-1}\end{bmatrix} (it's a row vector), and want to estimate

μh=E[Yh]=Xhβ\mu_{h}=\mathbb{E}[Y_{h}]=X_{h}\beta

by

μ^h=Xhb.\hat{\mu}_{h}=X_{h}b.

The sampling distribution of μ^h\hat{\mu}_{h} is

N(μh,σ2Xh(XTX)−1XhT)N\left( \mu_{h},\sigma^{2}X_{h}(X^TX)^{-1}X_{h}^T \right)

The estimated variance of μ^h\hat{\mu}_{h} is

s2(μ^h)=s2⋅Xh(XTX)−1XhTs^{2}(\hat{\mu}_{h})=s^{2}\cdot X_{h}(X^TX)^{-1}X_{h}^T

And we have

μ^h−μhs(μ^h)∼tn−p.\frac{\hat{\mu}_{h}-\mu_{h}}{s(\hat{\mu}_{h})}\sim t_{n-p}.

We can use this to conduct inference.

Prediction of a New Sample

We got Xh=[1Xh1…Xh,p−1]X_{h}=\begin{bmatrix}1 & X_{h 1} & \dots & X_{h,p-1}\end{bmatrix} (it's a row vector), and want to estimate

Yh=Xhβ+εhY_{h}=X_{h}\beta+\varepsilon_{h}

by

Y^h=Xhb.\hat{Y}_{h}=X_{h}b.

Here we assume εh⊥ε⃗\varepsilon_{h}\perp \vec{\varepsilon} and εh∼N(0,σ2)\varepsilon_{h}\sim N(0,\sigma^{2}).

The sampling distribution of Y^h−Yh\hat{Y}_{h}-Y_{h} is

N(0,σ2⋅(1+Xh(XTX)−1XhT))N\left( 0,\sigma^{2}\cdot({\color{red}1+}X_{h}(X^TX)^{-1}X_{h}^T) \right)

The estimated variance of Y^h−Yh\hat{Y}_{h}-Y_{h} is

s2(Y^h−Yh)=s2⋅[1+Xh(XTX)−1XhT]s^{2}(\hat{Y}_{h}-Y_{h})=s^{2}\cdot [1+X_{h}(X^TX)^{-1}X_{h}^T]

And we have

Y^h−Yhs(Y^h−Yh)∼tn−p.\frac{\hat{Y}_{h}-Y_{h}}{s(\hat{Y}_{h}-Y_{h})}\sim t_{n-p}.

We can use this to conduct inference.

Note that we focus on the difference dh=Y^h−Yhd_{h}=\hat{Y}_{h}-Y_{h} instead of Y^h\hat{Y}_{h} only, because the randomness of YhY_{h} must be considered.


YY 不同分布,为啥要看 YY 的分布?

  • 看有没有异常值

log⁡\log 变换

  • 相对变化率
  • 变换前三思,目标要不要保留单位?(愤怒的医生:医学指标必须保留单位!!)
  • 原假设被改变,\mathbb{E}[h(Y_{1})]=\mathbb{E}[h(Y_{2})] \centernot\implies \mathbb{E}[Y_{1}]=\mathbb{E}[Y_{2}].
  • 方差和期望平方成正比,log⁡\log 变换有用
  • 影响反变换回去的置信区间
  • 不直接回答原本关心的问题
  • 改变误差项的分布

替代方法:

  • GLM
  • resampling methods
  • non-parametric methods

抑制变量

  • 单独拿出来预测 YY,拉
  • 但是可以加强别的变量的解释能力

t-test 检查最后一个进来的变量(variable added last)的显著性,ANOVA 检查序贯进入的显著性。下节课细讲

模型选择,比较 Adjusted R2R^{2} 或者 MSEMSE,两者等价。

后面进的变量,只能带来前面变量正交补空间上的信息。

小的 R2R^{2} 不蕴含系数不显著。

  • R2R^{2} 管二阶矩
  • 回归系数管一阶矩
  • 两者没啥关系

8 Multiple Linear Regression: Example & Inference
https://wtx17.github.io/2026/11/10/Lec8-MLR-Example-and-Inference/
作者
wtx
发布于
2026年11月10日
更新于
2026年12月2日
许可协议