[R] R.squared in summary.lm with weights
Murray Efford
murray.efford at otago.ac.nz
Thu Apr 7 23:21:53 CEST 2016
Following some old advice on this list, I have been reading the code for summary.lm to understand the computation of R-squared from a weighted regression. Usually weights in lm are applied to squared residuals, but I see that the weighted mean of the observations is calculated as if the weights are on the original scale:
[...]
f <- z$fitted.values
w <- z$weights
[...]
m <- sum(w * f/sum(w))
[mss <-] sum(w * (f - m)^2)
[...]
This seems inconsistent to me. What am I missing?
Murray Efford
More information about the R-help
mailing list