[R] Pairwise comparison after repeated measures ANOVA

Dieter Menne dieter.menne at menne-biomed.de
Wed Feb 15 16:06:36 CET 2006


Felipe MartÃ­nez-Pastor <Felipe.Martinez <at> uclm.es> writes:

> 
> I am analyzing some data obtained after measuring some parameters at
> different times in samples obtained from many subjects. The model is
> quite simple: aov(parameter ~ Time + Error(Subject/Time))
> 
> Now I want to make a pairwise comparison between the levels of Time.
> However, I have not find how to do such a thing. I cannot use TukeyHSD
> or pairwise.t.test, I supposse. Maybe using contrasts?
> 

I would suggest that you use lme from package nlme for this type of a problem, 
because it provides a MUCH better toolbox fro what noadays is called mixed-
effect models. And get the book by Pinheiro/Bates (Mixed-Effect Models in S and 
S-PLUS), which is full of practical examples of this type.

With the results of <lme>, you can use <estimable> from package gmodels to 
estimate contrasts, and p.adjust to adjust for multiple comparison. However, as 
you parameter is called Time, you should really rethink if this is the right 
way to go. Why not treat Time as and continuous variable, effectively 
estimating a slope? Or at least as an ordered variable? I know from my clients 
that, after measuring a parameter 6 instances in time, they insist on a star-
spangled list of all 15 pairwise comparisons. If they do, I take out  
Bonferroni's Iron Claw even if I know better methods.

The question: "At what time intervals is the difference significant" is mostly 
nonsense.

Try to rephrase as "Is there a significant linear trend in time?". Would adding 
a quadratic component improve the quality of the fit (use AIC for this, see 
Pinheiro/Bates or Venables/Ripley). In many biological applications I know, a 
linear trend is perfectly fine, and it often has an easy interpretation. You 
only have to fight "but it's not linear" faculty, who mostly would not object 
to computing the mean without ever thinking to ask "but it's not constant".

Soapbox off. You see, I just had a discussion on the subject with a client.

Dieter




More information about the R-help mailing list