Show that $SS_\text{reg}=y^T(X(X^T X)^{-1}X^T-X_2(X_2^T X_2)^{-1}X_2^T)y$

29 Views Asked by At

If $X$ is the design matrix, show that:

$$SS_\text{reg}=y^T(X(X^T X)^{-1}X^T-X_2(X_2^T X_2)^{-1}X_2^T)y$$

where $X_2$ is a $n \times 1$ matrix with entries equal to one.

So far what I have done is that I know $SS_\text{reg}=\sum_{i=1}^n (y_i-\bar{y})^2=\sum_{i=1}^n\hat{y}^2-\frac{\sum_{i=1}^n(y_i)^2}n$

I have found that $\sum_{i=1}^n\hat{y}^2=y^T (X(X^T X)^{-1}X^T y$. However I am stuck at finding what $\frac{\sum_{i=1}^n(y_i)^2} n$ is. Any clue how I might approach it?