R's linear model summary object has a unscaled variance feature, which appears to be what is calculated when solve(t(X)%*%X)*sigma^2 is calculated directly. What makes this "unscaled" ? What is the alternative?
What makes it "unscaled" is that it's not scaled by the estimated variance sigma^2
, that is: solve(t(X) %*% X)
where X
refers to the design-matrix. This is in contrast to the (scaled) variance of the coefficients: solve(t(X) %*% X)*sigma^2
.
If you need the scaled variance, i.e. solve(t(X) %*% X)*sigma^2
, then you can simply scale it or use vcov()
. A small example follows:
x <- 1:100
y <- x + rnorm(100, 2)
fit <- lm(y ~ x)
summary(fit)$cov*summary(fit)$sigma^2 # One way
vcov(fit) # Another way