Standard set-up: $$ Y=X\beta+e $$ where $e\sim N(0,\Sigma)$
We know that the GLS estimate of $\beta$ is $\hat{\beta}=(X'\Sigma^{-1}X)^{-1}X'\Sigma^{-1}Y$
The (generalized) residual sum of square is then: \begin{align} SS(\hat{\beta})&=(Y-X\hat{\beta})'\Sigma^{-1}(Y-X\hat{\beta})\\ &=(Y-X(X'\Sigma^{-1}X)^{-1}X'\Sigma^{-1}Y)'\Sigma^{-1}(Y-X(X'\Sigma^{-1}X)^{-1}X'\Sigma^{-1}Y)\\ &=Y'\Sigma^{-1}Y-Y'\Sigma^{-1}X(X'\Sigma^{-1}X)^{-1}X'\Sigma^{-1}Y \end{align}
The second equality is by substituting $\hat{\beta}$ into the LHS, the third equality is by brute force expanding the brackets but I think it is just standard algebra stuff one do with least square problems. In fact, if $\Sigma$ is the Identity matrix it becomes $Y'(I-H)Y$ where $H$ is the 'hat- matrix'
The thing I got quite confused now is that, if I am correct, $$ \Sigma^{-1}X(X'\Sigma^{-1}X)^{-1}X'\Sigma^{-1}=\Sigma^{-1}\quad(*) $$ which would make $SS(\hat{\beta})=0$.
Which does not make sense, as $SS(\hat{\beta})$ is the objective function we try to minimize. Can someone tell me what I did wrong?
The way I got $(*)$ is by a bunch of factorization (inspired by this post):
We first use cholesky to get $\Sigma=LL'$ And QR to get $L^{-1}X=QR$ Therefore \begin{align} &\Sigma^{-1}X(X'\Sigma^{-1}X)^{-1}X'\Sigma^{-1}\\ =&(LL')^{-1}X(X'(LL')^{-1}X)^{-1}X'(LL')^{-1}\\ =&(LL')^{-1}X(R'Q'QR)^{-1}X'(LL')^{-1}\\ =&L'^{-1}QR(R'R)^{-1}R'Q'L^{-1}\\ =&L'^{-1}L^{-1}\\ =&\Sigma^{-1} \end{align}