In Linear regression $y = X\beta + \epsilon$ The Hat matrix is defined to be $H = X(X^TX)^{-1} X^T$ .
However. If I compute the equation for Hat matrix, I just get an identity matrix. My calculation is the following:
$X(X^TX)^{-1} X^T $
$= X(X^{-1} (X^T)^{-1})X^T$
$= (XX^{-1}) ((X^T)^{-1}X^T) $
$= I \times I $
$=I$
I know I must be doing something wrong because if the Hat matrix is just an identity matrix, it wouldn't have any significance. What did I do wrong here?