The manual page for sigma() claims that, for a linear model at least, the result is the same as summary(fit)$sigma. This is untrue if the lm fit has NA coefficients. The problem is that sigma.default uses the length of coef as a surrogate for degrees of freedom, it should use the number of non NA coefficients.
temp <- data.frame(x1 = LETTERS[c(1,2,3,1,2,3,1,2,3)],
x2 = letters[c(1,2,1,2,1,1,1,2,1)],
y = 1:9)
fit <- lm(y ~ x1*x2, data=temp)
sigma(fit) # 4.24
summary(fit)$sigma # 3.67
You are right.
I tend to agree that probably
should be changed to
but I do not start any action right now...
fixed in both R-devel and (R 3.4.1)-patched