G'day Gabor,

On Thu, 17 Mar 2011 20:38:21 -0400
Gabor Grothendieck <ggrothendi...@gmail.com> wrote:

> > Or am I missing something?

O.k., because the residuals don't add to zero, there may be a non-zero
correlation between residuals and fitted values, which messes up the
equation at the variance level.

> Try it on an example to convince yourself:
> 
> > fm <- lm(demand ~ Time, BOD)
> > var(fitted(fm)) + var(resid(fm)) - var(BOD$demand)
> [1] 3.552714e-15
> >
> > fm0 <- lm(demand ~ Time - 1, BOD)
> > var(fitted(fm0)) + var(resid(fm0)) - var(BOD$demand)
> [1] 59.28969

But, and this is of course the geometry of least squares:

R> sum(fitted(fm)^2) + sum(resid(fm)^2) - sum(BOD$demand^2)
[1] 0
R> sum(fitted(fm0)^2) + sum(resid(fm0)^2) - sum(BOD$demand^2)
[1] 2.273737e-13

and the reason why the formula changes if there is no (explicit)
intercept term in the model.

Cheers,

        Berwin

______________________________________________
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