# Re: [R] Strange R squared, possible error

From: Peter Ehlers <ehlers_at_ucalgary.ca>
Date: Thu, 17 Mar 2011 07:31:20 -0700

On 2011-03-17 02:08, derek wrote:
> Exuse me, I don't claim R^2 can't be negative. What I say if I get R^2
> negative then the data are useless.
> I know, that what Thomas said is true in general case. But in my special
> case of data, using nonzero intercept is nonsense, and to get R^2 less than
> 0.985 is considered poor job (standard R^2>0.995). (R^2 given by R^2 = 1 -
> Sum(R[i]^2) / Sum((y[i])^2) )
>
> Because lm() uses two differrent formulas for computing R^2,
> it is confusing to get R^2 closer to 1 when linear model with zero intercept
> y=a*x (a = slope) is used, rather than in case with model y=a*x+b (a=slope,
> b= nonzero intercept).
>
> I think R^2 is only measure of good fit for least squares optimization and
> it doesn't matter which formula is used: (R^2 = 1 - Sum(R[i]^2) /
> Sum((y[i])^2) or R^2 = 1 - Sum(R[i]^2) / Sum((y[i])^2-y*)), but using both
> is confusing.
>
> So I would like to know why two different formulas for R^2 are used?
>

The beauty of R is that you can study the code and if you don't like it, you can just write your own. I doubt that anyone here would be offended if you used whatever definition of R^2 you like best.

Thomas has explained clearly what R does and why. If you find R's usage confusing then your understanding of regression is lacking the depth required to apply it. You would probably benefit considerably from consulting a text or two on regression.

Peter Ehlers

>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Strange-R-squared-possible-error-tp3382818p3383992.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help