# Why can we replace dependent variable y with the residuals e?

I don't understand why we can replace y with e:

Mainly, why can we simply replace y with e, given that y is defined as:

You are not replacing $$y$$ with $$e$$. We are replacing $$y$$ with $$\hat{y}+\hat{e}$$, which is the fitted value of $$y$$, given by $$X\hat{\beta}$$, plus the estimated value of the residual, given by $$y-X\hat{\beta}$$. So, by construction, $$X\hat{\beta}+\hat{e}=X\hat{\beta}+y-X\hat{\beta}=y$$.

$$\big[ I-W(W'W)^{-1}W'+WC\big]y = \big[ I-W(W'W)^{-1}W'+WC\big](W\beta + e)$$

$$=\big[ I-W(W'W)^{-1}W'+WC\big]W\beta + \big[ I-W(W'W)^{-1}W'+WC\big] e$$

Analyzing the first term,

$$\big[ I-W(W'W)^{-1}W'+WC\big]W\beta = W\beta - W(W'W)^{-1}W'W\beta + WCW\beta$$

Simplyfying the inverse, we get

$$...= WCW\beta$$

So if $$CW = 0$$

the whole first term is zero.