Skip to content

R-squared with Intercept set to 0 (zero) for linear regression in R is incorrect

3 messages · Pamela Krone-Davis, William Dunlap

#
What does Excel give for the following data, where the by-hand formula
you gave is obviously wrong?
   > x <- c(1, 2, 3)
   > y <- c(13.1, 11.9, 11.0)
   > M1 <- lm(y~x+0)
   > sqerr <- (y- predict(M1)) ^ 2
   > sqtot <- (y - mean(y)) ^ 2
   > 1 - sum(sqerr)/sum(sqtot)
  [1] -37.38707

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
#
You might want to look at 
   http://support.microsoft.com/kb/214230
entitled
   Incorrect output is returned when you use the Linear Regression (LINEST) function in Excel

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com