4 Prediction and ANOVA

yyy">Estimation and Prediction about YY

Estimation of E[Yh]\mathbb{E}[Y_h]

At X=XhX=X_{h} the mean response is E[Yh]=β0+β1Xh\mathbb{E}[Y_h]=\beta_{0}+\beta_{1}X_{h}. We estimate it with

μ^h=b0+b1Xh\hat{\mu}_{h}=b_{0}+b_{1}X_h

Something about μ^h:\hat{\mu}_{h}:

  • Mean: Unbiased
  • Variance: Cov(Yˉ,b1)=0\mathrm{Cov}(\bar{Y},b_1)=0 is the key

σ2(μ^h)=σ2[1n+(Xh−Xˉ)2Sxx]\sigma^{2}(\hat{\mu}_{h})=\sigma^{2}\left[ \frac{1}{n}+ \frac{(X_{h}-\bar{X})^{2}}{S_{x x}} \right]

  • Under i.i.d. normal error terms μ^h∼N(μh,σ2(μ^))\hat{\mu}_{h}\sim N(\mu_{h},\sigma^{2}(\hat{\mu})).
  • μ^h−μhs(μ^h)∼tn−2\dfrac{\hat{\mu}_{h}-{\mu}_{h}}{s(\hat{\mu}_{h})}\sim t_{n-2}.

Note that the closer XhX_{h} is to Xˉ\bar{X}, the more precise μ^h\hat{\mu}_{h} is. That why we say 线性回归适合做内差而不是外推。

Based on this significance tests and CIs can be obtained. For example, 100(1−α)%100(1-\alpha)\% CI is

μ^h±tn−2,1−α/2s(μ^h).\hat{\mu}_{h}\pm t_{n-2,1-\alpha/2}s(\hat{\mu}_{h}).

Prediction of YhY_{h}

Model:

Yh=β0+β1Xh+εY_{h}=\beta_{0}+\beta_{1}X_{h}+\varepsilon

where ε\varepsilon is not any one among ε1,…,εN\varepsilon_{1},\dots,\varepsilon_N, but has the same property, say uncorrelated and having the same variance.

We still use μ^h\hat{\mu}_{h} to predict it. Here we need to consider ε\varepsilon. Let

dh=Yh−μ^hd_{h}=Y_{h}-\hat{\mu}_{h}

we have

  • Mean: Edh=0\mathbb{E}d_{h}=0.
  • Variance: The key is that ε⊥(ε1,…,εn)\varepsilon\perp (\varepsilon_{1},\dots,\varepsilon_{n}).

σ2(dh)=V[(β0−b0)+(β1−b1)Xh+ε]=σ2[1+1n+(Xh−Xˉ)2Sxx]\begin{align} \sigma^{2}(d_{h}) & = \mathbb{V}[(\beta_{0}-b_{0})+(\beta_{1}-b_{1})X_{h}{\color{red}+\varepsilon}] \\ & = \sigma^{2}\left[ {\color{red}1+}\frac{1}{n}+ \frac{(X_{h}-\bar{X})^{2}}{S_{x x}} \right] \end{align}

  • Under normal error terms

dh∼N(0,σ2(dh))d_{h}\sim N(0,\sigma^{2}(d_{h}))

  • dhs(dh)∼tn−2\dfrac{d_{h}}{s(d_{h})}\sim t_{n-2}.

The prediction intervals rely more on the normality assumption because ε\varepsilon is alone. There is no average to allow CLT to perform.

Mean of mm New Observations

We still use μ^h\hat{\mu}_{h} as the estimator. Let

d=1m∑i=1mYinew−μ^hd= \frac{1}{m}\sum_{i=1}^{m} Y_i^{new}-\hat{\mu}_{h}

Similarly

σ2(d)=⋯=σ2[1m+1n(Xh−Xˉ)2Sxx]\sigma^{2}(d)=\dots=\sigma^{2}\left[ {\color{red}\frac{1}{m}}+\frac{1}{n}\frac{(X_{h}-\bar{X})^{2}}{S_{x x}} \right]

Confidence Band

If L(x),U(x)L(x),U(x) (sample-dependent) satisfy

P[L(x)<β0+β1x<U(x) ∀x]=1−αP[L(x)<\beta_{0}+\beta_{1}x<U(x)\ \forall x]=1-\alpha

Then the 100(1−α)%100(1-\alpha)\% confidence band for the entire regression line is

{(x,y):L(x)<y<U(x),x∈R}\left\{ (x,y):L(x)<y<U(x), x \in \mathbb{R} \right\}

Note that we cannot just use the pointwise CIs to construct the confidence band. That is

∀x,P[L(x)<β0+β1x<U(x)]=1−α\forall x, P[L(x)<\beta_{0}+\beta_{1}x<U(x)]=1-\alpha

Note that the "∀\forall" changes place. It is a bit similar to the difference between single inference and joint inference.

Summary

Prediction intervals are the widest. Confidence band is a little wider than CIs.

ANOVA

ANalysis Of VAriance.

Decomposition of Variation

∑(Yi−Yˉ)2=∑(Y^i−Yˉ)2+∑(Yi−Y^i)2\sum(Y_{i}-\bar{Y})^{2}=\sum (\hat{Y}_{i}-\bar{Y})^{2}+\sum (Y_{i}-\hat{Y}_{i})^{2}

which is

SST=SSR+SSESST = SSR + SSE

  • T: Total
  • R: Regression
  • E: Error
  • It can be interpreted as an orthogonal decomposition

In some literature, R stands for residual and E stands for explained. In that sense, the meaning is completely different.

Let's see their degrees of freedom:

  • SST: n−1n-1, easy to understand
  • SSR: 11. It's because SSR=b12SxxSSR=b_{1}^{2}S_{x x}. It's defined by b1b_{1}.
  • SSE: n−2n-2.

MST,MSR,MSEMST,MSR,MSE are defined by SST,SSR.SSESST,SSR.SSE divided by their dfs.


As for the expectations, SSTSST and SSESSE are easier to compute.

E(Yi−Yˉ)2=E(β1(Xi−Xˉ)+εi−εˉ)2=β12(Xi−Xˉ)2+n−1nσ2  ⟹  E(SST)=β12Sxx+(n−1)σ2\begin{align} \mathbb{E}(Y_{i}-\bar{Y})^{2} & = \mathbb{E}(\beta_{1}(X_{i}-\bar{X})+\varepsilon_{i}-\bar{\varepsilon})^{2} \\ & = \beta_{1}^{2}(X_i-\bar{X})^{2}+ \frac{n-1}{n}\sigma^{2} \\ \implies \mathbb{E}(SST)& = \beta_{1}^{2}S_{x x}+ (n-1)\sigma^{2} \end{align}

And

E(SSE)=(n−2)σ2\mathbb{E}(SSE)=(n-2)\sigma^{2}

So

E(SSR)=β12Sxx+σ2\mathbb{E}(SSR)=\beta_{1}^{2}S_{x x}+\sigma^{2}

Expected Mean Squares

E[MSR]=σ2+β12SxxE[MSE]=σ2\begin{align} \mathbb{E}[MSR] & =\sigma^{2}+\beta_{1}^{2}S_{x x} \\ \mathbb{E}[MSE] & =\sigma^{2} \end{align}

When β1=0\beta_{1}=0, they equals to each other.

Let's Have a Deeper Look at DF

The model

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

Suppose rank(X)=k\mathrm{rank}(X)=k, full column rank. Then the projection matrix of XX

P=X(XTX)−1XTP=X(X^TX)^{-1}X^T

has the same rank as XX. Note that Y^=PY\hat{Y}=PY. So

SSE=∥Y^−Y∥2=∥(P−I)Y∥2SSE=\|\hat{Y}-Y\|^{2}=\|(P-I)Y\|^{2}

has df of n−kn-k, because rank(P−I)=n−k\mathrm{rank}(P-I)=n-k.

SST=∥Y−1n11TY∥2=∥(I−1n11T)Y∥2SST = \| Y-\frac{1}{n} \boldsymbol{1}\boldsymbol{1}^TY \|^{2}=\|(I-\frac{1}{n} \boldsymbol{1}\boldsymbol{1}^T)Y\|^{2}

has df of n−1n-1 because rank(I−1n11T)=n−1\mathrm{rank}(I-\frac{1}{n} \boldsymbol{1}\boldsymbol{1}^T)=n-1.

1n11T\frac{1}{n} \boldsymbol{1}\boldsymbol{1}^T is the projection matrix of 1\boldsymbol{1}.

SSR=⋯=∥(P−1n11T)Y∥2SSR=\dots=\|(P-\frac{1}{n} \boldsymbol{1}\boldsymbol{1}^T)Y\|^{2}

has df of k−1k-1 because rank(P−1n11T)=k−1\mathrm{rank}(P-\frac{1}{n} \boldsymbol{1}\boldsymbol{1}^T)=k-1.

Let J=1n11TJ=\frac{1}{n} \boldsymbol{1}\boldsymbol{1}^T. Then JJ is the projection matrix of a subspace of R(P)\mathcal{R}(P). So R(P)\mathcal R(P) can continue to be divided into two orthogonal subspaces:

R(P)=R(P−J)⊕R(J)\mathcal{R}(P)=\mathcal{R}(P-J)\oplus\mathcal{R}(J)

Therefore rank(P)=rank(P−J)+rank(J)\mathrm{rank}(P)=\mathrm{rank}(P-J)+\mathrm{rank}(J).


Moreover, SST=SSR+SSESST=SSR+SSE because

P−J⊥I−PP-J \perp I-P

(It is easy to verify -- the multiplication is OO.)

All thing above can be put in a nutshell:

Y=PY+(I−P)Y=(P−J)Y+JY+(I−P)Y\begin{align} Y & ={\color{blue}PY}+(I-P)Y \\ & = {\color{blue}(P-J)Y+JY}+(I-P)Y \end{align}

Subsequent orthogonal decomposition. In this note we will show that (I−P)Y(I-P)Y can continue to be orthogonally decomposed.

F-test

H0:β1≠0H_0: \beta_{1}\ne 0

When this holds, MSR tends to be larger than MSE. And because they all follow chi-square distribution and they are independent, we can set

F=MSRMSE∼FdfR,dfEF=\frac{MSR}{MSE}\sim F_{df_{R},df_{E}}

as the test statistic. When it's large enough, we can reject H0H_0 according to our significance level.

General Linear Test

A different view of the simple F-test.

459

The principle is to compare the SSE of each model. The full model should have less SSE because we hope it can do better. More generally, the F-statistic should be written as

[SSE(R)−SSE(F)]/(dfER−dfEF)SSE(F)/dfEF\frac{[SSE(R)-SSE(F)]/(df_{ER}-df_{EF})}{SSE(F)/df_{EF}}


4 Prediction and ANOVA
https://wtx17.github.io/2026/10/13/Lec4-Prediction-and-ANOVA/
作者
wtx
发布于
2026年10月13日
更新于
2026年11月6日
许可协议