# [R] repeated measures anova, sphericity, epsilon, etc

Peter Dalgaard p.dalgaard at biostat.ku.dk
Tue Mar 3 22:00:53 CET 2009

```Paul Gribble wrote:
> I have 3 questions (below).
>
> Background: I am teaching an introductory statistics course in which we are
> covering (among other things) repeated measures anova. This time around
> teaching it, we are using R for all of our computations. We are starting by
> covering the univariate approach to repeated measures anova.
>
> Doing a basic repeated measures anova (univariate approach) using aov()
> seems straightforward (e.g.:
>
> +> myModel<-aov(myDV~myFactor+Error(Subjects/myFactor),data=myData)
> +> summary(myModel)
>
> Where I am currently stuck is how best to deal with the issue of the
> assumption of homogeneity of treatment differences (in other words, the
> sphericity assumption) - both how to test it in R and how to compute
> corrected df for the F-test if the assumption is violated.
>
> Back when I taught this course using SPSS it was relatively straightforward
> - we would look at Mauchly's test of sphericity - if it was significant,
> then we would use one of the corrected F-tests (e.g. Greenhouse-Geisser or
> Huynh-Feldt) that were spat out automagically by SPSS.
>
> I gather from searching the r-help archives, searching google, and searching
> through various books on R, that the only way of using mauchly.test() in R
> is on a multivariate model object (e.g. mauchly.test cannot handle an aov()
> object).
>
> Question 1: how do you (if you do so), test for sphericity in a repeated
> measures anova using R, when using aov()? (or do you test the sphericity
> assumption using a different method)?
>
> Question 2: Can someone point me to an example (on the web, in a book,
> wherever) showing how to perform a repeated measures anova using the
> multivariate approach in R?
>
> Question 3: Are there any existing R functions for calculating adjusted df
> for Greenhouse-Geisser, Huynh-Feldt (or calculating epsilon), or is it up to
> me to write my own function?
>
> Thanks in advance for any suggestions,

Have a look at

http://cran.r-project.org/doc/Rnews/Rnews_2007-2.pdf

Last time this came up, John Fox also pointed to some of his stuff, see
http://finzi.psych.upenn.edu/R/Rhelp08/archive/151282.html

--
O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)              FAX: (+45) 35327907

```