I found an answer to my question on this thread: Repeated measures ANOVA with lme in R for two within-subject factorsRepeated measures ANOVA with lme in R for two within-subject factors (somehow this thread was already one of my favorites, I must have forgotten about it). The specification is a little unhandy.
m6 <- lme(mean ~ condition*group*problem*topic,
random = list(code=pdBlocked(list(~1, pdIdent(~problem-1), pdIdent(~topic-1)))), data = d)
anova(m6)
However, the denominator dfs are still wrong, as noted in the threadthread and apparent in comparisons between the ANOVA and lme
dfs.
data.frame(effect = rownames(anova(m6)), denDf= anova(m6)$denDF)
m4$ANOVA[,c("Effect", "DFd")]
As long as there are no other ideas, I think I will need to do the analysis in lme4
, for which I wil need to post another question.