[R] Fixed and random factors in aov()

Ioannis Dimakos idimakos at upatras.gr
Fri Jul 16 11:24:20 CEST 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dimitris Rizopoulos wrote:


maybe the following is working?

aov(Points~Game*Store+Error(subj+Store:subj))

IKD



| Hi Sven,
|
| I think that you could also use `lme', i.e., something like:
|
| library(nlme)
| lme1 <- lme(Points~Game, random=~1|Store, data=kh.df)
| lme2 <- lme(Points~Game, random=~1|Store/Game, data=kh.df)
|
| anova(lme1)
| anova(lme2)
| anova(lme1, lme2)
|
| I hope this helps.
|
|  -======
|
|>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
|>


- --
Ioannis Dimakos
University of Patras
Dept. of Elementary Education
Division of Psychology
Patras, GR-26500, Greece
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFA957D+es8s84M8DARAvPTAJ4l48lNp4xG/SxnpPd4t4RP0aO0GwCeK4BM
eKQAXZiJgaQ5M/Df3vNiEBQ=
=QBdB
-----END PGP SIGNATURE-----




More information about the R-help mailing list