# Prove that $\sum \hat y_i(y_i-\hat y_i)=0$ for linear regression model

Prove that $$\sum \hat y_i(y_i-\hat y_i)=0$$ for linear regression model.

Attempt

We have that $$\sum \hat y_i(y_i-\hat y_i)=\sum x_i\hat\beta(x_i\beta-x_i\hat\beta)=(X\hat\beta)'(X\beta)-(X\hat\beta)'(X\hat\beta)=\hat\beta'X'X\beta-\hat\beta'X'X\hat\beta= \ ?$$

• Plug in $\hat \beta = (X'X)^{-1}X'Y$ to see if you can get the result. – user158565 Oct 27 '18 at 23:32
• Hint: look at the first order conditions that define $\hat{\beta}$ – probabilityislogic Oct 27 '18 at 23:32
$$\sum \hat y_i(y_i-\hat y_i)=\sum x_i\hat\beta(y_i-x_i\hat\beta)=(X\hat\beta)'Y-(X\hat\beta)'(X\hat\beta)=\hat\beta'X'Y-\hat\beta'X'X\hat\beta= \hat\beta'X'Y-\hat\beta'X'X(X'X)^{-1}X'Y = \hat\beta'X'Y - \hat\beta'X'Y = 0$$