[R] PROC MIXED vs. lme()

Christophe Pallier pallier at lscp.ehess.fr
Wed Dec 10 16:04:15 CET 2003


 >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;
 >run;

 >
 >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() ))

This yields the correct results (I converted all the factors into... 
factors). Note that the 'trial' factor is fixed.

Actually you do not need lme for that. You could use the aov function:

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

(it works well because the data is balanced)


Christophe Pallier
http://www.pallier.org




More information about the R-help mailing list