Hi,
This is as question that has been asked many times on the R-mailing list,
but has never been satisfyingly answered (as far as I could see). Is it
possible to specify a mixed effects model "equivalent" to a
repeated-measures ANOVA with two or more crossed within subjects factors? I
can easily get the same f-values when I have only one within-subjects
factor, but I have problems to get same results with two within-subjects
factors. It is my understanding that the lmer-function would be more
appropriate for such a model, since it can more easily handle crossed random
effects.
#Here's a simple repeated measures ANOVA with two balanced within subjects
factors:
df<-data.frame(Time=as.factor(rep(paste('t',1:3,sep=''),each=36)),
Cond=as.factor(paste('c',1:4,sep='')),
Subj=as.factor(rep(paste('s',1:9,sep=''),each=4) ),y=rnorm(108))
#Here are the results, that I get with the traditional repeated measures
approach using aov:
summary(aov(y ~ (Time*Cond) + Error(Subj/(Time*Cond)), data = df))
#With lmer I tried the following, but get slightly different results:
library(lme4)
anova(lmer(y~Time*Cond+(1|Subj)+(1|Subj:Time)+(1|Subj:Cond),df))
#Interestingly, when I try a model that has only 2 levels for each within
subject factor I get the same results:
datafilename="http://personality-project.org/r/datasets/R.appendix4.data"
data.ex4=read.table(datafilename,header=T)
summary(aov(Recall~(Task*Valence)+Error(Subject/(Task*Valence)),data.ex4 ))
anova(lmer(Recall~Task*Valence+(1|Subject)+(1|Task:Subject)+(1|Valence:Subje
ct),data.ex4))
I would like to know, whether there is a lmer or lme specification, that
would exactly replicate the results of aov? I know that an exact replication
would not necessarily be the best model from a theoretical point of view and
therefore would probably not make a lot of sense, but it would probably help
me to better understand the differences between the two approaches.
Many thanks,
Erich
________________________________________________
Erich Studerus
Lic. Phil. Klinische Psychologie
Psychiatric University Hospital Zurich
Division of Clinical Research
Lenggstr. 31
CH-8008 Zurich
Switzerland
Mail: erich.studerus@bli.uzh.ch
Office: +41 44 384 26 66
Mobile: +41 76 563 31 54
________________________________________________
[[alternative HTML version deleted]]