[R] lm without intercept, false R-squared

Uwe Ligges ligges at statistik.tu-dortmund.de
Wed Jun 27 13:15:13 CEST 2012



On 27.06.2012 10:36, Christof Kluß wrote:
>
> for example the same model with intercept R² = 0.6, without intercept R²
> = 0.9 and higher. In my definition of R², R² has to be equal or less
> without intercept
>
> I do not know what R shows, but in the summary of the model without
> intercept it does not show the R² of the regression line.
>
> When I run a regression I like to have the R² of the regression line and
> not something else. ;)

Ah, now I understand your question, see ?summary.lm:

r.squared: R^2, the ‘fraction of variance explained by the model’,

                     R^2 = 1 - Sum(R[i]^2) / Sum((y[i]- y*)^2),

           where y* is the mean of y[i] if there is an intercept and
           zero otherwise.


With your definition of  R^2 you can use:

1 - crossprod(residuals(model)) / crossprod(y - mean(y))

while R uses:

1 - crossprod(residuals(model)) / crossprod(y - 0)


Best,
Uwe Ligges





>
>
>
>
> Am 27-06-2012 10:25, schrieb Uwe Ligges:
>>
>>
>> On 27.06.2012 09:33, Christof Kluß wrote:
>>> Hi
>>>
>>> is there a command that calculates the correct adjusted R-squared, when
>>> I work without intercept? (The R-squared from lm without intercept is
>>> false.)
>>
>> Then we need your definition of your version of "correct" - we know the
>> definition of your version of "false".
>>
>> Best,
>> Uwe Ligges
>>
>>
>>>
>>> Greetings
>>> Chrsitof
>>>
>>> ______________________________________________
>>> R-help at 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.
>>>
>>
>>
>
>



More information about the R-help mailing list