Calculation of r.squared for linear model with offset

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Calculation of r.squared for linear model with offset

Ross Darnell
R^2 for a model is usually defined as 1-RSS/TSS where TSS is the SS
about the mean and RSS is the residual SS from the model.

Consider the model in R

z <- runif(20)
y <- z+rnorm(20)
my.model <- lm(y~offset(z))
summary(my.model)$r.squared

Here the RSS is equivalent to the TSS and
gives 0 when it should (IMHO and a few others perhaps) be

1 - RSS/TSS(corrected for the mean only)

RSS = sum(resid(my.model)^2)
TSS = sum((y-mean(y))^2)

Have I missed this somewhere in the FAQ's or elsewhere?

Regards
Ross Darnell

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: Calculation of r.squared for linear model with offset

Prof Brian Ripley
On Sun, 9 Apr 2006, Ross Darnell wrote:

> R^2 for a model is usually defined as 1-RSS/TSS where TSS is the SS
> about the mean and RSS is the residual SS from the model.

Not when there is no intercept or where there is an offset in the model.

> Consider the model in R
>
> z <- runif(20)
> y <- z+rnorm(20)
> my.model <- lm(y~offset(z))
> summary(my.model)$r.squared
>
> Here the RSS is equivalent to the TSS and
> gives 0 when it should (IMHO and a few others perhaps) be
> 1 - RSS/TSS(corrected for the mean only)
>
> RSS = sum(resid(my.model)^2)
> TSS = sum((y-mean(y))^2)

Those are not the correct formulae in the presence of an offset.

> Have I missed this somewhere in the FAQ's or elsewhere?

Elsewhere.  The offset is subtracted from y.

--
Brian D. Ripley,                  [hidden email]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html