[R] Why aov() with Error() gives three strata?

Jorge Fernando Saraiva de Menezes jorgefernandosaraiva at gmail.com
Thu Dec 28 16:52:47 CET 2017

Dear list users,

I am trying to learn Repeated measures ANOVA using the aov() interface, but
I'm struggling to understand its output.

According to tutorials on the web, formula for a repeated measures design

aov(Y ~ IV+ Error(SUBJECT/IV) )

This formula does work but it returns three strata (Error:SUBJECT, Error:
SUBJECT:IV, Error: Within), when I would expect two strata (Within and
Between subjects). I've seems some tutorials  show the exactly same setup,
but returning only the two first strata.

Is it possible to have two or three strata depending on the data?
If there is always three strata, how this would fit the interpretation of
between vs within effects?

Below a reproducible example that gives three strata:

data=data.frame(id =
#balance dataset to have 6 samples for every combination of beaver and
balanced = split(data,interaction(data$id,data$activ))
sizes = sapply(balanced,nrow)
selected = lapply(sizes,sample.int,6)
balanced = mapply(function(x,y) {x[y,]}, balanced,selected,SIMPLIFY=F)
balanced = do.call(rbind,balanced)


	[[alternative HTML version deleted]]

More information about the R-help mailing list