dreamer
dreamer

Reputation: 1202

Covariance Matrix lm object R

This should be really easy, but is there a built-in function in R to get an unbiased estimate of the variance covariance model of an lm object? And then I mean $\epsilon \epsilon' / (n-k-1)$? Because using cov(lm$resid) does not adjust for the number of variables $k$, or does it?

I know how to program this manually of course, but I was just curious whether there is no built-in function. Thanks in advance.

Upvotes: 2

Views: 1255

Answers (1)

usεr11852
usεr11852

Reputation: 294

I believe that, assuming the fitted model lm1, you want simply summary(lm1)$sigma.

Yes, your intuition is correct; cov(lm$resid) will not adjust for the degrees of freedom.

Upvotes: 2

Related Questions