Show $y^Ty-n^{-1}(\sum y_i)^2=y^T(I-n^{-1}1_n1_n^T)y=\sum(y_i-\bar y)^2$?

49 Views Asked by At

Here is the picture of my notes: Notes

How does $y^Ty-n^{-1}(\sum y_i)^2=\sum(y_i-\bar y)^2$?

I can see that: $y^Ty-n^{-1}(\sum y_i)^2=y^T(I-n^{-1}1_n1_n^T)y$

I also see that $\frac{n}{n^2}(\sum y_i)^2=n\bar y^2$

1

There are 1 best solutions below

1
On BEST ANSWER

What you may be missing is that $y^Ty=\sum_iy_i^2$, so that

$$\begin{align*} y^Ty-\frac1n\left(\sum_iy_i\right)^2&=\sum_iy_i^2-\frac1n\left(\sum_iy_i\right)^2\\ &=\sum_iy_i^2-\frac1n(n\bar y)^2\\ &=\sum_iy_i^2-n\bar y^2\;. \end{align*}$$

On the other hand,

$$\begin{align*} \sum_i(y_i-\bar y)^2&=\sum_i\left(y_i^2-2\bar yy_i+\bar y^2\right)\\ &=\sum_iy_i^2-2\bar y\sum_iy_i+n\bar y^2\\ &=\sum_iy_i^2-2\bar y(n\bar y)+n\bar y^2\\ &=\sum_iy_i^2-n\bar y^2\;, \end{align*}$$

so

$$y^Ty-\frac1n\left(\sum_iy_i\right)^2=\sum_I(y_i-\bar y)^2\;.$$