[R-sig-teaching] Random effet ANOVA, presentation like the classic one.
Christophe Genolini
cgenolin at u-paris10.fr
Thu Jan 8 15:40:38 CET 2015
Hi the list,
I am teaching ANOVA with R. The classic case is quite easy:
#--- 8< ---------------
n <- 8 # number of individual in each group.
kSport <- 3 # kA number of sport groups
kSchool <- 2 # kB Number of possible school
set.seed(1)
size <- rep(c(-10+15,+20+15,-10+15,-10-15,+30-15,-20-15),each=n)+rnorm(n*kSport,170,10)
sport <- factor(rep(rep(paste("a",1:kSport,sep=""),each=n),kSchool))
school <- factor(rep(paste("b",1:kSchool,sep=""),each=n*kSport))
summary(aov(size~sport+school+sport:school))
Df Sum Sq Mean Sq F value Pr(>F)
sport 2 13955 6978 68.91 5.46e-14 ***
school 1 10800 10800 106.65 4.25e-13 ***
sport:school 2 800 400 3.95 0.0268 *
Residuals 42 4253 101
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#--- 8< --------------
The model with some random effect is :
#--- 8< --------------
summary(aov(size~Error(sport+school+sport:school)))
#--- 8< --------------
But I did not get the computation of the f (fSportSchool=400/101.3=3.960 ; fsport=6978/400=17.445
and fSchool=10800/400=27).
So is there a way to get them?
I would like to get:
#--- 8< --------------
Df Sum Sq Mean Sq F value Pr(>F)
sport 2 13955 6978 17.445 ?
school 1 10800 10800 27.000 ?
sport:school 2 800 400 3.960 ?
Residuals 42 4253 101
#--- 8< --------------
Thanks for you help.
Christophe
More information about the R-sig-teaching
mailing list