In base R, what do the unweighted residuals from weighted least squares (WLS) represent? Below I estimate ordinary least squares (OLS) and calculate the residual standard error (RSE). Then I estimate WLS and calculate the RSE with the weighted residuals. All is good. But why does the RSE from WLS using the unweighted residuals not match the RSE from OLS using the unweighted residuals?
set.seed(1)
x <- rnorm(25)
y <- 5 * x + rnorm(25)
unweighted <- lm(y ~ x)
summary(unweighted)
sqrt(sum(resid(unweighted)^2) / 23)
w <- 1:25
weighted <- lm(y ~ x, weights = w)
summary(weighted)
sqrt(sum(weighted.residuals(weighted)^2) / 23)
sqrt(sum(w * resid(weighted)^2) / 23)
sqrt(sum(resid(weighted)^2) / 23)