[R] Strange R squared, possible error

Thomas Lumley tlumley at uw.edu
Wed Mar 16 22:44:22 CET 2011


On Thu, Mar 17, 2011 at 10:01 AM, derek <jan.kacaba at gmail.com> wrote:
> It states summary.lm:
>
> r.squared       R^2, the ‘fraction of variance explained by the model’,
>
> R^2 = 1 - Sum(R[i]^2) / Sum((y[i]- y*)^2),
>
> where y* is the mean of y[i] if there is an intercept and zero otherwise.
>
> Why to use different formula when intercept is set to zero?

Multiple reasons (or ways to state the same reason)

1) Otherwise the r^2 could be negative

2) If you set the slope to zero in the model with a line through the
origin you get fitted values y*=0

3) The model with constant, non-zero mean is not nested in the model
with a line through the origin.

All these come down to saying that if you know a priori that E[Y]=0
when x=0 then the `null' model to compare to the fitted line, the
model where x doesn't explain any of the variance, is the model where
E[Y]=0 everywhere.

If you don't know a priori that E[Y]=0 when x=0 you shouldn't be
fitting a line through the origin.

    -thomas

-- 
Thomas Lumley
Professor of Biostatistics
University of Auckland



More information about the R-help mailing list