I am trying to Derive the Estimated Variance of Regression Coefficients. I am struggling with the algebra.
Here is the model:
$$y = X\beta + \epsilon$$ $$\hat{\beta} = (X^TX)^{-1}X^Ty$$
First, we find out the expectation:
$$E(\hat{\beta}) = E((X^TX)^{-1}X^Ty) = E((X^TX)^{-1}X^T(X\beta + \epsilon)) = \beta + (X^TX)^{-1}X^TE(\epsilon)$$
Next, we find out the squared expectation:
$$E(\hat{\beta}^2) = E((X^TX)^{-1}X^Ty((X^TX)^{-1}X^Ty)^T) = E((X^TX)^{-1}X^Tyy^TX(X^TX)^{-1})$$
Substituting $y = X\beta + \epsilon$ gives:
$$E(\hat{\beta}^2) = E((X^TX)^{-1}X^T(X\beta + \epsilon)(X\beta + \epsilon)^TX(X^TX)^{-1}) = \beta\beta^T + E((X^TX)^{-1}X^T\epsilon\epsilon^TX(X^TX)^{-1})$$
Assuming that the errors are uncorrelated and homoscedastic, this simplifies to:
$$E(\hat{\beta}^2) = \beta\beta^T + \sigma^2(X^TX)^{-1}$$
Finally, we can evaluate Var($\hat{\beta}$) = E($\hat{\beta}^2$) - E($\hat{\beta}$)^2 :
$$\text{Var}(\hat{\beta}) = \beta\beta^T + \sigma^2(X^TX)^{-1} - \beta^2 = \sigma^2(X^TX)^{-1}$$
Is this the correct derivation?