# Tukey's HSD following repeated measures ANOVA using ezANOVA package

#### dlutter

##### New Member
Hi,
I have a longitudinal balanced tendon injury study with two treatment groups of horses (n=6/group) with 5 measurements over 6 mos measured on multiple MRI sequences. I have multiple questions with how I want to analyze this information, but my current question is the most pressing:

Below is an example of the script I ran in RStudio looking at tendon volume on a proton density MRI sequence:

ezANOVA(data=mri,dv=.(Ten.V.PD),wid=.(Horse),within=.(Date),between=.(Treatment,Age),detailed=TRUE)

It gave an output showing an effect of Date and Age: Date. For some parameters it is also showing an effect of Age alone.

Is it possible to do Tukey's multiple comparisons on Age, Date, and Age: Date immediately following the ezANOVA?

I have seen examples online of TukeyHSD using aov fit but not with repeated measures. Also, I am unfamiliar with the aov syntax. If I need to learn about aov and re-run everything in order to do this, I will. However, I would like to avoid that at this time, if possible.

FYI, I am newer than a newbie at R and programming. I am trying frantically to learn enough about R to complete the stats for my thesis ASAP. I could explain more of why I turned to R with such a short time line if anyone wants to hear me whine, but it is off topic and doesn't change the fact that I need to get this done.

Also, I have installed RCommander and feel like I could use that if RStudio is inadequate for the job. I'm not sure I could do this in stock R without serious hand holding and step by step instructions.

I would appreciate any advice you may have. Thanks.

#### ted00

##### New Member
I don't think I can reliably pull out your study question from your post
also, have you plotted the data yet? that's a great way to see if your model results are making sense, and R happens to be great for making graphs

#### dlutter

##### New Member
Thank you for the reply. I have done some graphing in Excel, but not in R because of my discomfort with the code at the moment. Based on the graphs I have done it makes sense there may be an effect.

My biggest question for posting here is: Is it possible to perform Tukey HSD test after running a repeated measures ANOVA using the ez package. All of the examples I have seen show example code using Tukey HSD after running the ANOVA using aov.

#### nickx

##### New Member
Hello,
maybe it can help you : Tukey is not the best way to control first type error in repeated measure. Andy Field suggests that Bonferroni is better. You can make all the pairwise comparisons as follow :
pairwise.t.test(longdata1$value, longdata1$variable, paired=TRUE, p.adjust.method="bonferroni")
Other methods for adjust p exist. Probably, the best is the Holm correction which is possible with pairwise.t.test.
I had a similar problem with the orthogonal contrast, which was not the same between R and SPSS. You can check the answer, it is very clear and helpful.
Hope that it helps you.

#### dlutter

##### New Member
Hello,
maybe it can help you : Tukey is not the best way to control first type error in repeated measure. Andy Field suggests that Bonferroni is better. You can make all the pairwise comparisons as follow :
pairwise.t.test(longdata1$value, longdata1$variable, paired=TRUE, p.adjust.method="bonferroni")
Other methods for adjust p exist. Probably, the best is the Holm correction which is possible with pairwise.t.test.
I had a similar problem with the orthogonal contrast, which was not the same between R and SPSS. You can check the answer, it is very clear and helpful.
Hope that it helps you.
Thank you for the suggestion. It does help. I had also been considering Bonferroni but was steered toward Tukey for some reason from my reading.

In the code, when you say "(longdata1$value, longdata1$variable", is that the name of the column where the data is listed in long form? This is the output when I ran it that way. I had to put Date in parenthesis to get it to not report an error:

Pairwise comparisons using paired t tests

data: Ten.V.PD and "Date"

<0 x 0 matrix>

I'm guessing there are some details that need to be defined before I run the test to get it to work? I'm happy to supply more info but am just not sure what to post.

Last edited:

#### nickx

##### New Member
Hi,
from my view, if this code is working

ezANOVA(data=mri,dv=.(Ten.V.PD),wid=.(Horse),within=.(Date),between=.(Treatment,Age),detailed=TRUE)

Than, this one should also works :
pairwise.t.test(mri$Ten.V.PD,mri$Date,paired=TRUE,p.adjust.method="bonferroni")