Given random variabes $Y_1,\dots,Y_n$ with mean $\mu$ and variance $\sigma^2$, I am supposed to prove that the sum of $(Y_i-(\text{mean of }y))^2$ can be expressed as
$$y^T\left(I_{n\times n} - \frac{1}{n}\begin{pmatrix}1\\1\\\vdots\\1\end{pmatrix}\begin{pmatrix}1&1&\dots&1\end{pmatrix}\right)y.$$
So, I am getting the general idea behind this. One thing that is bugging me is the identity matrix. In place of the identity matrix intuitively I feel that there should be a vector of data, the $Y_i$'s. Any guidance would be great. I really want to grasp linear regression using linear algebra. Thanks!