[R] Calculation of r.squared for linear model with offset
Ross Darnell
r.darnell at uq.edu.au
Sun Apr 9 13:25:14 CEST 2006
R^2 for a model is usually defined as 1-RSS/TSS where TSS is the SS
about the mean and RSS is the residual SS from the model.
Consider the model in R
z <- runif(20)
y <- z+rnorm(20)
my.model <- lm(y~offset(z))
summary(my.model)$r.squared
Here the RSS is equivalent to the TSS and
gives 0 when it should (IMHO and a few others perhaps) be
1 - RSS/TSS(corrected for the mean only)
RSS = sum(resid(my.model)^2)
TSS = sum((y-mean(y))^2)
Have I missed this somewhere in the FAQ's or elsewhere?
Regards
Ross Darnell
More information about the R-help
mailing list