I have a weighted least square model and I wanted to calculate $R^2$ manually, but my results don't match the R summary. Why is that?
> head(weights(m))
[1] 0.973411 0.408694 0.414370 0.426554 0.357159 0.407986
> yhat = predict(m)
> y = as.numeric(model.frame(m)[,1])
> SStot = sum((y - mean(y))^2)
> SSres = sum((y - yhat)^2)
> rsq = 1 - (SSres / SStot)
> rsq
[1] 0.065211
> summary(m)$r.squared
[1] 0.0433978
The same formulas give me the correct $R^2$ when using ordinary least square.