Proof that: $I-X(X^TX)^{-1}X^T=((I-X(X^TX)^{-1}X^T)^2$ I have to verify if the statment: 
$$I-X(X^TX)^{-1}X^T=((I-X(X^TX)^{-1}X^T)^2$$
is true or not. (I do not get to demonstrate).
Any help or hint will be very useful for me. Thanks a lot! 
 A: First let me warn everyone who reads this that $X$ is not supposed to be a square matrix; it is a matrix with typically many more rows than columns.  Its columns must be linearly independent since otherwise $X^T X$ is not invertible.
Let $H= X(X^T X)^{-1} X^T$.  Then
$$
H^2 = \Big( X (X^TX)^{-1} X^T \Big) \Big( X (X^TX)^{-1} X^T \Big) = X \Big( (X^T X)^{-1}(X^T X) (X^T X)^{-1}\Big) X^T
$$
and then the obvious cancelation yields
$$
= X(X^T X)^{-1} X^T = H.
$$
Next,
$$
(I-H)^2 = (I - H)(I - H) = I^2 - HI - IH + H^2 = I - H - H + H = I-H,
$$
so $I-H$ is idempotent, i.e. it is its own square.
A: $P_X = X(X^{T}X)^{-1}X^{T}$ is known as the projection matrix onto $\mathcal{C}(X)$, the column space of $X$. Note that since $r(X^TX) = r(X)$, if $X$ is a $n \times p$ matrix, $X$ needs to have rank $p$.
Your statement is equivalent to showing that $I - P_X$ is idempotent. 
Observe
$$(I - P_X)^2 = (I - P_X)(I - P_X) = I^2-2P_X+P_X^2\text{.}$$
Now
$$P_X^2 = X(X^{T}X)^{-1}X^{T}X(X^{T}X)^{-1}X^{T} = X(X^{T}X)^{-1}X^{T} = P_X$$
and obviously $I = I^2$, so $(I - P_X)^2 = I - 2P_X + P_X = I - P_X$, as desired.
