线性回归分析-HW7

HW.

Prob1 KNNL5.4 KNNL5.12

5.4

We have

Y=[7.89.010.211.011.7]TX=[11111840−4−8]TY= \begin{bmatrix} 7.8 & 9.0 & 10.2 & 11.0 & 11.7 \end{bmatrix}^T\\ X= \begin{bmatrix} 1 & 1 & 1 & 1 & 1 \\ 8 & 4 & 0 & -4 & -8 \end{bmatrix}^T

therefore

YTY=503.77XTX=[500160]XTY=[49.7−39.2]Y^TY=503.77\\ X^TX= \begin{bmatrix} 5 & 0 \\ 0 & 160 \end{bmatrix}\\ X^TY= \begin{bmatrix} 49.7 \\ -39.2 \end{bmatrix}

5.12

(XTX)−1=[15001160](X^TX)^{-1}= \begin{bmatrix} \frac{1}{5} & 0 \\ 0 & \frac{1}{160} \end{bmatrix}

Prob2 KNNL 5.23

2-a

Estimated regression coefficients

b=(XTX)−1XTY=[9.94−0.245]b=(X^TX)^{-1}X^TY= \begin{bmatrix} 9.94 \\ -0.245 \end{bmatrix}

Vector of residuals

e=Y−Xb=[−0.180.040.260.08−0.2]Te=Y-Xb=\begin{bmatrix} -0.18 & 0.04 & 0.26 & 0.08 & -0.2 \end{bmatrix}^T

SSR

SSR=∥Xb−Yˉ∥2=9.604SSR=\|Xb-\bar{Y}\|^{2}=9.604

SSE

SSE=∥e∣∣2=0.148SSE=\|e||^{2}=0.148

Estimated variance-covariance matrix of bb:

Cov^(b)=MSE⋅(XTX)−1=[0.00986667000.00030833]\widehat{\mathrm{Cov}}(b)=MSE\cdot(X^TX)^{-1}= \begin{bmatrix} 0.00986667 & 0 \\ 0 &0.00030833 \end{bmatrix}

Point estimate of E[Yh]\mathbb{E}[Y_{h}] when Xh=−6X_{h}=-6:

Y^h=[1−6]b=11.41\hat{Y}_{h}=\begin{bmatrix} 1 & -6 \end{bmatrix}b=11.41

Estimated variance of Y^h\hat{Y}_{h} when Xh=−6X_{h}=-6:

V[Y^h]=σ2⋅xT(XTX)−1XT⋅X(XTX)−1x=σ2⋅xT(XTX)−1xV^[Y^h]=MSE⋅xT(XTX)−1x=0.02096\mathbb{V}[\hat{Y}_{h}]=\sigma^{2}\cdot x^T(X^TX)^{-1}X^T\cdot X(X^TX)^{-1}x=\sigma^{2}\cdot x^T(X^TX)^{-1}x\\ \hat{\mathbb{V}}[\hat{Y}_{h}]=MSE\cdot x^T(X^TX)^{-1}x=0.02096

2-b

XTXX^TX is diagonal.

2-c

H=X(XTX)−1XT=[0.60.40.20.0−0.20.40.30.20.10.00.20.20.20.20.20.00.10.20.30.4−0.20.00.20.40.6]H=X(X^TX)^{-1}X^T= \begin{bmatrix} 0.6 & 0.4 & 0.2 & 0.0 & -0.2 \\ 0.4 & 0.3 & 0.2 & 0.1 & 0.0 \\ 0.2 & 0.2 & 0.2 & 0.2 & 0.2 \\ 0.0 & 0.1 & 0.2 & 0.3 & 0.4 \\ -0.2 & 0.0 & 0.2 & 0.4 & 0.6 \end{bmatrix}

and rank(H)=rank(X)=2\mathrm{rank}(H)=\mathrm{rank}(X)=2.

Verify HH is idempotent:

2-d

Cov(e)=σ2(I−H)\mathrm{Cov}(e)=\sigma^{2}(I-H)

therefore

s2(e)=MSE⋅(I−H)=[0.019733−0.019733−0.0098670.0000000.009867−0.0197330.034533−0.009867−0.0049330.000000−0.009867−0.0098670.039467−0.009867−0.0098670.000000−0.004933−0.0098670.034533−0.0197330.0098670.000000−0.009867−0.0197330.019733]s^{2}(e)=MSE\cdot(I-H)= \begin{bmatrix} 0.019733 & -0.019733 & -0.009867 & 0.000000 & 0.009867 \\ -0.019733 & 0.034533 & -0.009867 & -0.004933 & 0.000000 \\ -0.009867 & -0.009867 & 0.039467 & -0.009867 & -0.009867 \\ 0.000000 & -0.004933 & -0.009867 & 0.034533 & -0.019733 \\ 0.009867 & 0.000000 & -0.009867 & -0.019733 & 0.019733 \\ \end{bmatrix}

Bonus Question

Let

X=[X1…Xn]T, a=[a1…an]TX= \begin{bmatrix} X_{1} & \dots & X_{n} \end{bmatrix}^T,\, a= \begin{bmatrix} a_{1} & \dots & a_{n} \end{bmatrix}^T

Then

Y=aTX, E[X]=0, Var(X)=[1p…pp1…p⋮⋮⋱⋮pp…1]Y=a^TX,\ \mathbb{E}[X]=0,\ \mathrm{Var}(X)= \begin{bmatrix} 1 & p & \dots & p \\ p & 1 & \dots & p \\ \vdots & \vdots & \ddots & \vdots\\ p & p & \dots & 1 \end{bmatrix}

So

E[Y]=aTE[X]=0V[Y]=aTVar[X]a=aT((1−p)I+p11T)a=(1−p)∑i=1nai2+p(∑i=1nai)2\mathbb{E}[Y]=a^T\mathbb{E}[X]=0\\ \mathbb{V}[Y]=a^T\mathrm{Var}[X]a=a^T((1-p)I+p\boldsymbol{1}\boldsymbol{1}^T)a=(1-p)\sum_{i=1}^{n} a_{i}^{2}+p\left( \sum_{i=1}^{n} a_{i} \right)^{2}

Let S1=∑ai2,S2=(∑ai)2S_{1}=\sum a_{i}^{2},S_{2}=\left( \sum a_{i} \right)^{2}. With Cauchy-Schwarz Inequality we have nS1≥S2nS_{1}\geq S_{2}. pp have to ensure that V[Y]≥0, ∀a∈Rn\mathbb{V}[Y]\geq 0,\ \forall a\in \mathbb{R}^{n}.

When S1≤S2S_{1}\leq S_{2}, pp have to satisfy

p≥S1S1−S2=11−S2/S1≥11−np\geq \frac{S_{1}}{S_{1}-S_{2}}=\frac{1}{1-S_{2}/S_{1}}\geq \frac{1}{1-n}

When S1>S2S_{1}>S_{2}, pp have to satisfy

p≤S1S1−S2p\leq \frac{S_{1}}{S_{1}-S_{2}}

which is guaranteed because p≤1p\leq 1 and S1S1−S2>1\frac{S_{1}}{S_{1}-S_{2}}> 1.

So in all, the minimum of pp is 11−n\frac{1}{1-n}.

Think a bit deeper about this conclusion: if we want to impose a shared correlation on nn standardized r.v.s, then the imposition cannot be too hard. Take n=3n=3 as an example. If we impose a shared correlation of −1-1. Intuitively thinking, X1X_{1} goes inversely against X2X_{2}, and X2X_{2} goes inversely against X3X_{3}, then X3X_{3} should goes consistently with X1X_{1}. So X1X_{1} and X3X_{3} cannot be negatively correlated.


线性回归分析-HW7
https://wtx17.github.io/2026/11/04/线性回归分析-HW7/
作者
wtx
发布于
2026年11月4日
更新于
2026年11月6日
许可协议