3

I and some of my students have searched for a solution to this in numerous places with no luck and literally for months. I keep on being referred to the lme command which I do NOT want to use. The output provided is not the one my colleagues or myself have used for over 15 years. Moreover given I am using R as a teaching tool, it does not flow as well following t-tests, and one-way anovas for intro stats students. I am conducting a two way RM ANOVA with one factor repetition. I have succeeded in getting R to replicate what Sigmaplot gives for the main effects. However the post hoc analysis given by R differs significantly from the same post hoc in Sigmaplot. Here is the code I used - with notes (as I am using this also to teach students).

#IV between: IVB1 - Independent variable - between subject factor
#IV within: IVW1  - Independent variable - within subject factor
#DV: DV           - Dependent variable.

aov1= aov(DV ~ IVB1*IVW1 + Error(Subject/IVW1)+(IVB1), data=objectL)
summary(aov1)

# post hoc analysis
ph1=TukeyHSD(aov(DV ~ IVB1*IVW1, data=objectL))
ph1

I hope somebody can help. Thank you!

Steve
  • 31
  • 3

1 Answers1

0

I have also had this problem and I find convenient alternative with the aov_ez() function from the afex package instead of aov(), and then performed post hoc analysis using lsmeans() instead of TukeyHSD():

model <- aov_ez(data,                           
            id="SubjID",                     
            dv="DV",                         
            within=c("IVW1", "IVW2"), 
            between = "IVB1")

# Post hoc
comp = lsmeans(model,specs = ~ IVB1: IVW1: IVW2, adjust = "tukey")
contrast(comp,method="pairwise")

You will find a detailed tutorial here:

https://www.psychologie.uni-heidelberg.de/ae/meth/team/mertens/blog/anova_in_r_made_easy.nb.html