Terias wrote:
Hello,

I was doing a linear regression with the following formula:
lm(y~x+0), so it passes through the origin. But when I called the summary of
the regression i saw that R squared is abnormally high (it's a lot lower in
other programs such as SigmaPlot and MS Excel).The manual explained the
cause of the difference (because of the different computing method), but
what should I do to get the same R^2 in excel and R?


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....



WITHOUT PASSING THROUGH THE ORIGIN:
R^2: Multiple R-squared: 0.9711,     Adjusted R-squared: 0.9654
In MS Excel: 0,9711

So it's OK.


WITH PASSING THROUGH THE ORIGIN:
Multiple R-squared: 0.9848,     Adjusted R-squared: 0.9822
In MS Excel: 0,8907

So almost 10% difference.

Thank you for your help.

Csanad Bertok, Hungary



--
   O__  ---- Peter Dalgaard             Ă˜ster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalga...@biostat.ku.dk)              FAX: (+45) 35327907

______________________________________________
R-help@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.

Reply via email to