Re: [R] Fixed and random factors in aov()

From: Ioannis Dimakos <idimakos_at_upatras.gr>
Date: Fri 16 Jul 2004 - 19:24:20 EST

-----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
|>

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



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 19:30:24 2004

This archive was generated by hypermail 2.1.8 : Wed 03 Nov 2004 - 22:55:02 EST