Re: [R] Strange R squared, possible error

From: Thomas Lumley <tlumley_at_uw.edu>
Date: Thu, 17 Mar 2011 10:44:22 +1300

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

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Wed 16 Mar 2011 - 21:47:48 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 17 Mar 2011 - 01:30:22 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive