Skip to content

lm without intercept, false R-squared

9 messages · Peter Dalgaard, Mikko Korpela, Christof Kluß +2 more

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

Greetings
Chrsitof
#
On 27.06.2012 09:33, Christof Klu? wrote:
Then we need your definition of your version of "correct" - we know the 
definition of your version of "false".

Best,
Uwe Ligges
#
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. ;)




Am 27-06-2012 10:25, schrieb Uwe Ligges:

  
    
#
On Jun 27, 2012, at 09:33 , Christof Klu? wrote:

            
When people say that, they are usually implying that a "correct" R-squared can be negative!

If for some reason you want to use an alternative *definition* of R^2, it should be easy enough to calculate it yourself, e.g. (if the proportion reduction in variance is wanted):

Y <- rnorm(100, 10, 1)
x <- 1:100
(var(Y) - summary(lm(Y~x-1))$sigma^2)/var(Y)

(comes out as -31 or so)
#
On 06/27/2012 10:33 AM, Christof Klu? wrote:
Hi! This answer in R-FAQ might help you:

http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-does-summary_0028_0029-report-strange-results-for-the-R_005e2-estimate-when-I-fit-a-linear-model-with-no-intercept_003f
#
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. ;)




Am 27-06-2012 10:25, schrieb Uwe Ligges:

  
    
#
On 27.06.2012 10:36, Christof Klu? wrote:
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
#
On Jun 27, 2012, at 13:15 , Uwe Ligges wrote:

            
And the reason why that is not used in R:
[,1]
[1,] -27.60012
#
On Wed, Jun 27, 2012 at 4:36 AM, Christof Klu? <ckluss at email.uni-kiel.de> wrote:
If we use a baseline with no intercept in the R^2 definition then
adding the intercept will always improve the R^2 or at least not make
the R^2 worse.  The following r.squared.0 function defines such an
R^2. It will agree with the R^2 produced by R when used with models
having no intercept but will give a different R^2 value for models
with an intercept.

  r.squared.0 <- function(fm) c(1 / (1 + crossprod(resid(fm)) /
crossprod(fitted(fm))))

  fm1 <- lm(demand ~ Time, BOD)
  fm0 <- lm(demand ~ Time-1, BOD)

  r.squared.0(fm0)
  r.squared.0(fm1) # adding intercept increases r.squared.0

  # for comparison
  # summary(fm0) uses same defn as r.squared.0
  # but summary(fm1) does not

  summary(fm0)$r.squared # does agree with ours
  summary(fm1)$r.squared # does not agree with ours