Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the "effects" returned by `aov` and `lm`?

I would like to ask the difference between $coefficients and $effects in aov output.

Here the f1 factor and the interaction f1 * f2 are significant. I want to interpret the effect of that factor on the response and I thought that the $effects is what I needed.

Let’s consider the following simple following data set.

f1 <- c(1,1,0,0,1,1,0,0)
f2 <- c(1,0,0,1,1,0,0,1)
r <- c(80, 50, 30, 10, 87,53,29,8)
av <- aov(r ~ f1 * f2)
summary(av)
av$coefficients
av$effects
plot(f1, r)

It seems that the response is being increased by 48.25 units because of f1 mean(r[f1==1]) - mean(r[f1==0]).

But I can’t really see that on $effects output. What does the $effects output really tell me?

like image 851
Lefty Avatar asked Oct 24 '16 21:10

Lefty


1 Answers

Effects are rotated response values according to the QR factorization for design matrix. Check:

all.equal(qr.qty(av$qr, r), unname(av$effects))
# [1] TRUE

Effects are useful for finding regression coefficients from QR factorization:

all.equal(backsolve(av$qr$qr, av$effects), unname(coef(av)))
# [1] TRUE

They can also be used to find fitted values and residuals:

e1 <- e2 <- av$effects
e1[(av$rank+1):length(e1)] <- 0
e2[1:av$rank] <- 0

all.equal(unname(qr.qy(av$qr, e1)), unname(fitted(av)))
# [1] TRUE

all.equal(unname(qr.qy(av$qr, e2)), unname(residuals(av)))
# [1] TRUE

So in summary, effects are representation of data at rotated domain, and is all least square regression is about.

like image 65
Zheyuan Li Avatar answered Oct 16 '22 14:10

Zheyuan Li