[R] Fixed and random factors in aov()

From: Sven Garbade <garbade_at_mip.paed.uni-muenchen.de>
Date: Fri 16 Jul 2004 - 18:36:53 EST


Hi,
I'm confused about how to specify random and fixed factors in an aov() term. I tried to reproduce a textbook example: One fixed factor (Game, 4 levels) and one random factor (Store, 12 levels), response is Points. The random factor Store is nested in Game. I tried

> str(kh.df)

`data.frame': 48 obs. of 4 variables:

 $ Subj  : Factor w/ 48 levels "vp1","vp10","vp11",..: 1 12 23 34 44... 
 $ Game  : Factor w/ 4 levels "S1","S2","S3",..: 1 1 1 1 1 1 1 1 ... 
 $ Store : Factor w/ 12 levels "KH1","KH10","KH11",..: 1 1 1 1 5 ... 
 $ Points: num  7 9 12 7 6 5 8 6 9 6 ...

> summary(aov(Points ~ Game + Error(Game:Store),dat=kh.df))

Error: Game:Store

          Df Sum Sq Mean Sq F value  Pr(>F)  
Game       3 391.50  130.50  5.9771 0.01934 *
Residuals  8 174.67   21.83                  
---
Signif. codes:  0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 

Error: Within
          Df  Sum Sq Mean Sq F value Pr(>F)
Residuals 36 149.500   4.153               
Warning message: 
Error model is singular in: aov(Points ~ Game + Error(Game:Store), dat =
kh.df) 

which gives me the correct F-statistic for the fixed factor Game and 


> summary(aov(Points ~ Game + Game:Store,dat=kh.df))
Df Sum Sq Mean Sq F value Pr(>F) Game 3 391.50 130.50 31.4247 3.707e-10 *** Game:Store 8 174.67 21.83 5.2575 0.0002126 *** Residuals 36 149.50 4.15 --- Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1
which calcultes the correct Game:Store F statistic but the incorrect F value for Game (because its a fixed factor). I'm wondering about how to specify a correct model formula for the fixed and random factors with an appropiate Error() term. Thanks, Sven ______________________________________________ R-help@stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Fri Jul 16 18:44:11 2004

This archive was generated by hypermail 2.1.8 : Fri 18 Mar 2005 - 02:36:39 EST