[R] Structure of Anova for obtaining sig. corrected for departure from sphericity

John Fox jfox at mcmaster.ca
Wed Dec 15 16:43:13 CET 2010

Dear dror,

If I understand correctly what you want to do, the setup is similar to the
O'Brien-Kaiser example in ?Anova, only simpler.

First, you have to reorganize your data in "wide" format so that there's one
record for each subject, with response variables (say) present.C and

Then fit the multivariate linear model mod <- lm(cbind(present.C, present.D)
~ group, data=Data), where Data is the wide dataset and group gives the
order of presentation, with levels (say) "CD" and "DC". 

Next, create the within-subjects "data," idata <-
data.frame(present.type=c("C", "D")). 

Finally, perform the ANOVA, summary(Anova(mod, idata=idata,

I hope this helps,

John Fox
Senator William McMaster 
  Professor of Social Statistics
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
web: socserv.mcmaster.ca/jfox

> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
> Behalf Of Dror D Lev
> Sent: December-15-10 5:41 AM
> To: r-help at r-project.org
> Subject: [R] Structure of Anova for obtaining sig. corrected for departure
> from sphericity
> Dear helpers,
> I have a 2x2 mixed design with two "groups" (between-subjects) and two
> presentation-types (within-subjects).
> The difference between groups is in the order of manipulations:
> group.CD having first a block of present.type.C and then a block of
> present.type.D, each block containing 31 trials.
> group.DC having first a block of present.type.D and then a block of
> present.type.C, each block containing 31 trials.
> I'm mostly interested in the interaction group:present.type - to see if
> order of presentation has an influence on performance time (the dependent
> measure).
> The fundamental ANOVA model is:
> >aov(t.total~group*present.type+Error(subj/present.type), data=dat2)
> Unfortunately, the standard deviations of the different interaction-cells
> differ markedly (~20, ~9, ~9, ~18) so it seems that a correction for
> departure from sphericity is appropriate.
> I'm trying to achieve that using the Anova function from the car package,
> but fail to understand what should be the model, the idata and idesign
> parameter (which seem to be required for a repeated-measures analysis
> design).
> I'd appreciate any help with getting the right required model and
> (idata, idesign and icontrasts).
> Thanks,
> dror
> --------------------
> My data set is stored in a data.frame with the following columns:
> > names(dat2)
> [1] "t.total"      "t.err"        "trial.num"    "subj"
> "present.type"
> [6] "ord"          "group"        "dat.name"
> and the only table of results I'm getting is:
> > summary(Anova(m.tmp))
>      Sum Sq             Df           F value          Pr(>F)
>  Min.   : 17810   Min.   :  1.0   Min.   :69.01   Min.   :1.278e-15
>  1st Qu.: 41232   1st Qu.:108.8   1st Qu.:69.01   1st Qu.:1.278e-15
>  Median : 64654   Median :216.5   Median :69.01   Median :1.278e-15
>  Mean   : 64654   Mean   :216.5   Mean   :69.01   Mean   :1.278e-15
>  3rd Qu.: 88075   3rd Qu.:324.2   3rd Qu.:69.01   3rd Qu.:1.278e-15
>  Max.   :111497   Max.   :432.0   Max.   :69.01   Max.   :1.278e-15
>                                   NA's   : 1.00   NA's   :1.000e+00
> 	[[alternative HTML version deleted]]
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list