s-news
[Top] [All Lists]

Re: lm question

To: Jason Connor <jconnor@bio.ri.ccf.org>
Subject: Re: lm question
From: Prof Brian Ripley <ripley@stats.ox.ac.uk>
Date: Fri, 15 Dec 2000 18:51:08 +0000 (GMT)
Cc: s-news@wubios.wustl.edu
In-reply-to: <Pine.SOL.3.96.1001215131900.26113T-100000@foster>
On Fri, 15 Dec 2000, Jason Connor wrote:

> The following is a simple example to illustrating a bizarre feature I
> noticed.

Not bizarre, as it is as normally defined.

> The problem relates to the multiple r-squared value obtained using lm.
> 
> The following creates two vectors, x and y. 
> 
> > x_seq(1,10,length=100)
> > y_2+x*4+rnorm(100,0,4)
> > plot(x,y)
> 
> Now perform two fits:
> 
> > fit.a_lm(y~x)
> > fit.c_lm(y~rep(1,100)+x-1)
> 
> As you can see fit.a and fit.c are the same fit. fit.c says fit without an
> intercept but fit with a vector of 1's.  As one would expect, the
> coefficients from the two models are the same:
> 
> > coef(fit.a)
>  (Intercept)        x 
>     1.512145 4.173989
> 
> > coef(fit.c)
>  rep(1, 100)        x 
>     1.512145 4.173989
> 
> 
> The R^2 values, however, are not the same.
> 
> > summary(fit.a)$r.squared
> [1] 0.8680936
> > summary(fit.c)$r.squared 
> [1] 0.9752623
> 
> 
> It seems as if the R^2 value from fit.a is correct:
> 
> > cor(fitted(fit.a),y)^2
> [1] 0.8680936
> > cor(fitted(fit.c),y)^2
> [1] 0.8680936
> 
> 
> Any explanations as to the different behavior?

The definitions are different.  If you omit the intercept from the model,
the sums of squares are about zero, not the mean, or, equivalently,
the correlations are not centred.  If you did not do that, you could get 
R^2 of less than zero.

Both are correct, but your intepretation is faulty.

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595


<Prev in Thread] Current Thread [Next in Thread>
  • lm question, Jason Connor
    • Re: lm question, Prof Brian Ripley <=