Skip to content
Prev 205878 / 398506 Next

R^2 in linear regression

Terias wrote:
If you insist, I think you can get what Excel does like this:

 > x <- 1:10
 > y <- rnorm(10)

## Residual sums of squares
 > ss1 <- anova(lm(y~1))[1,2]
 > ss2 <- anova(lm(y~x+0))[2,2]

## Relative reduction in sum of squares
 > (ss1-ss2)/ss1
[1] -0.08576713

Now if you dislike the fact that R^2 can come out negative, that's your 
problem....