[R] PROC MIXED vs. lme()

Christophe Pallier pallier at lscp.ehess.fr
Wed Dec 10 16:00:06 CET 2003


Hi

 >I'm trying to learn how to do a repeated measures ANOVA in R using lme().
 >In SAS, I use the code:
 >
 >PROC MIXED DATA=[data set below];
 >  CLASS sub group trial;
 >  MODEL dv = group trial group*trial;
 >  REPEATED trial / SUBJECT=sub TYPE=CS;
 >
 >In R, I'm trying the code:
 >
 >results.cs <- lme(DV ~ factor(GROUP)*factor(TRIAL), data=[data set below],
 >random= ~factor(TRIAL)|SUB, correlation=corCompSymm() )
 >anova(results.cs)

Try

$ anova(lme(DV ~ GROUP*TRIAL,random= ~1|SUB, correlation=corCompSymm() ))

It yields the correct result (I converted all the factors into factors). 
Trial is a fixed, not random factor.

Actually, you do not need lme for to run a repeated measure anova.
You could use the aov function:

$ summary(aov(DV~GROUP*TRIAL+Error(SUB/TRIAL)))

This, again, yields the correct results.
Hope this helps,


Christophe Pallier
http://www.pallier.org




More information about the R-help mailing list