Sometimes you may wish to run a mixed ANOVA - an ANOVA with both between and within factors. Again, in R this is easy to do.
Imagine you have data from two groups (men and women) at two time points (week one, week ten). See the plot below.
Imagine you have data from two groups (men and women) at two time points (week one, week ten). See the plot below.
Assuming that the men are on the left and women are on the right, you might hypothesize that men have greater scores at Week Ten as opposed to on Week One, whereas there was no difference between scores for women at Week One and Week Ten. You could test this with a mixed ANOVA.
Load the data HERE.
Use the following commands to run a mixed ANOVA:
my.data = read.table('mixedANOVAData.txt')
names(my.data) = c('Subject','Group','Time','RT')
my.data$Subject = factor(my.data$Subject)
my.data$Group = factor(my.data$Group)
my.data$Time = factor(my.data$Time)
myMixedANOVA = aov(RT ~ Group + Time + Group*Time + Error(Subject / Time), data = my.data)
print(summary(myMixedANOVA))
boxplot(my.data$RT ~ my.data$Time*my.data$Group)
Note that in the ANOVA model Group is not included in the error term so it is treated as a Between subjects factor whereas Time is included in the error term so it is treated as a within subjects factor. Finally, there is an interaction term that specifies the interaction between the between (Group) and within (Time) subjects factors. You should see the output below:
Load the data HERE.
Use the following commands to run a mixed ANOVA:
my.data = read.table('mixedANOVAData.txt')
names(my.data) = c('Subject','Group','Time','RT')
my.data$Subject = factor(my.data$Subject)
my.data$Group = factor(my.data$Group)
my.data$Time = factor(my.data$Time)
myMixedANOVA = aov(RT ~ Group + Time + Group*Time + Error(Subject / Time), data = my.data)
print(summary(myMixedANOVA))
boxplot(my.data$RT ~ my.data$Time*my.data$Group)
Note that in the ANOVA model Group is not included in the error term so it is treated as a Between subjects factor whereas Time is included in the error term so it is treated as a within subjects factor. Finally, there is an interaction term that specifies the interaction between the between (Group) and within (Time) subjects factors. You should see the output below:
The top portion is the result for the between subjects analysis of Group. The bottom portions are the results for the within subjects analysis of Time and the Group by Time interaction.