What does function “effects” in R do?

I don’t understand the explanation in R‘s help file for effects():

For a linear model fitted by lm or aov, the effects are the uncorrelated single-degree-of-freedom values obtained by projecting the data onto the successive orthogonal subspaces generated by the QR decomposition during the fitting process.

Can anybody explain what this means?

Are the orthogonal subspaces alluded to the one dimensional subspaces spanned by the columns of the Q-part of the QR-decomposition (and hence orthogonal to each other)? Or are they supposed to be orthogonal to something else?


Given the response vector y, explanatory variable matrix X and its QR decomposition X=QR, the effects returned by R is the vector QTy.

Here is the numeric example which confirms the above:

> set.seed(1001)
> x<-rnorm(100)
> y<-1+2*x+rnorm(100)
> mod<-lm(y~x)
> xqr<-qr(cbind(1,x))
> sum(abs(qr.qty(xqr,y)-effects(mod)))
[1] 0

Source : Link , Question Author : Vincent , Answer Author : mpiktas

Leave a Comment