# [R] How to get Greenhouse-Geisser epsilons from anova?

John Fox jfox at mcmaster.ca
Tue Dec 9 20:34:20 CET 2008

```Dear Nils,

> -----Original Message-----
> From: Skotara [mailto:nils.skotara at uni-hamburg.de]
> Sent: December-09-08 12:21 PM
> To: John Fox
> Cc: 'Peter Dalgaard'; r-help at r-project.org
> Subject: Re: [R] How to get Greenhouse-Geisser epsilons from anova?
>
> Dear John and Peter,
>
> thank you both very much for your help!
> Everything works fine now!
>
> John, Anova also works very fine. Thank you very much!
> However, if I had more than 2 levels for the between factor the same
> thing as mentioned occured.
> The degrees of freedom showed that Anova calculated it as if all
> subjects came from the same group, for example for main effect A the dfs
> are 1 and 35.

That is odd -- the example that I sent had a factor with 3 levels, producing
2 df; here's a simplified version with s single between-subject factor
(treatment):

> OBrienKaiser\$treatment
[1] control control control control control A       A       A       A
[10] B       B       B       B       B       B       B
attr(,"contrasts")
[,1] [,2]
control   -2    0
A          1   -1
B          1    1
Levels: control A B

> mod.ok <- lm(cbind(pre.1, pre.2, pre.3, pre.4, pre.5,
+                       post.1, post.2, post.3, post.4, post.5,
+                       fup.1, fup.2, fup.3, fup.4, fup.5) ~  treatment,
+                data=OBrienKaiser)

> av.ok <- Anova(mod.ok, idata=idata, idesign=~phase*hour)

> summary(av.ok, multivariate=FALSE)

Univariate Type II Repeated-Measures ANOVA Assuming Sphericity

SS num Df Error SS den Df       F    Pr(>F)
treatment            186.75      2   416.58     13  2.9139  0.090041 .
phase                167.50      2    92.17     26 23.6257 1.419e-06 ***
treatment:phase       77.00      4    92.17     26  5.4304  0.002578 **
hour                 106.29      4    72.81     52 18.9769 1.128e-09 ***
treatment:hour         0.89      8    72.81     52  0.0798  0.999597
phase:hour            11.08      8   116.96    104  1.2319  0.287947
treatment:phase:hour   5.96     16   116.96    104  0.3312  0.992574
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Mauchly Tests for Sphericity

Test statistic p-value
phase                       0.85151 0.38119
treatment:phase             0.85151 0.38119
hour                        0.09859 0.00194
treatment:hour              0.09859 0.00194
phase:hour                  0.00837 0.09038
treatment:phase:hour        0.00837 0.09038

Greenhouse-Geisser and Huynh-Feldt Corrections
for Departure from Sphericity

GG eps Pr(>F[GG])
phase                0.87071  5.665e-06 ***
treatment:phase      0.87071   0.004301 **
hour                 0.48867  1.016e-05 ***
treatment:hour       0.48867   0.986835
phase:hour           0.50283   0.308683
treatment:phase:hour 0.50283   0.950677
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

HF eps Pr(>F[HF])
phase                0.99390  1.515e-06 ***
treatment:phase      0.99390   0.002641 **
hour                 0.57413  2.190e-06 ***
treatment:hour       0.57413   0.992771
phase:hour           0.75630   0.298926
treatment:phase:hour 0.75630   0.981607
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

I didn't save your earlier postings, so can't check your model and data. If
you like, please feel free to send them to me privately.

Regards,
John

> Since I can get those values using anova that causes no problem.
>
> I saw that the x\$G to get the greenhouse-geisser epsilon do work for:
> x<- anova(mlmfitD, X=~C+B, M=~A+C+B, test = "Spherical")
> but does not work for y\$G:
> y <- anova(mlmfit, mlmfit0, X= ~C+B, M = ~A+C+B, idata =
> dd,test="Spherical")
>
> Finally, the Greenhouse-Geisser epsilons are identical using both
> methods and to the SPSS output.
> The Huynh-Feldt are not the same as them of SPSS. I will use GG instead.

```