[R] R-squared value for linear regression passing through origin using lm()
tlumley at u.washington.edu
Fri Oct 19 17:58:37 CEST 2007
On Fri, 19 Oct 2007, Ralf Goertz wrote:
> Thanks to Thomas Lumley there is another convincing example. But still
> I've got a problem with it:
>  0.75
> That's okay, but neither
>  0.97076
>  0.9805066
> give the result of summary(lm(y~x+0)), which is 0.9796.
It isn't var(residuals)*(n-1) but sum(residuals^2) that you want. They are not the same in a zero-intercept model, because the residuals need not have mean zero.
Thomas Lumley Assoc. Professor, Biostatistics
tlumley at u.washington.edu University of Washington, Seattle
More information about the R-help