[R] Proof for computing sums of squares

Douglas Bates bates at stat.wisc.edu
Mon Jan 3 19:32:52 CET 2011

On Mon, Jan 3, 2011 at 12:15 PM, Ethan Arenson
<ethan.a.arenson at gmail.com> wrote:
> Hi.
> I know that R computes sums of squares based on the diagonal of
> t(Q) %*% y %*% t(y) %*% Q,
> where Q comes from the QR-decomposition of the model matrix.

So, how do you know that?  When I look at the code for summary.lm I
see the residual sum of squares being computed as

r <- z$residuals
rss <- sum(r^2)

Also, your formula is not correct.  I think you mean the trace of that
matrix which is the squared length of Q'y and that's the same as the
squared length of y.  The matrix Q in a QR decomposition is orthogonal
and one of the properties of orthogonal matrices is that they preserve
lengths.  So the length of Qy is the same as the length of Q'y is the
same as the length of y.

> Does anyone know where I can find a proof for this result?
> All Best and Happy New Year,
> Ethan
>        [[alternative HTML version deleted]]
> ______________________________________________
> 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