Skip to content
Prev 301593 / 398503 Next

lm without intercept

Hi,

R actually uses a different formula for calculating the R square
depending on whether the intercept is in the model or not.

You may also find this discussion helpful:
http://stats.stackexchange.com/questions/7948/when-is-it-ok-to-remove-the-intercept-in-lm/

If you conceptualize R^2 as the squared correlation between the
oberserved and fitted values, it is easy to get:

summary(m0 <- lm(mpg ~ 0 + disp, data = mtcars))
summary(m1 <- lm(mpg ~ disp, data = mtcars))
cor(mtcars$mpg, fitted(m0))^2
cor(mtcars$mpg, fitted(m1))^2

but that is not how R calculates R^2.

Cheers,

Josh
On Sat, Jul 28, 2012 at 10:40 AM, citynorman <citynorman at hotmail.com> wrote: