Exercise

Anova: Multiple comparisons (2)

In R a handy function to follow up an Anova with pairwise comparisons is the pairwise.t.test() function. pairwise.t.test() takes an argument x that is the name of your response variable, followed by the argument g = where you tell the function your grouping variable. Furthermore, you can choose an adjusment method for the p value by specifying the p.adj parameter. For instance, if you want to do a Bonferroni correction or a Holm correction, you can specify set the p.adj argument to either p.adj = "bonf" or p.adj = "holm". So all in all the usage of the pairwise t test should look something like this:

pairwise.t.test(dependent_variable, g = grouping_variable, p.adj = "bonf")

Another often used correction for multiple testing is the Tukey method. To use this in R, you can use the TukeyHSD() function. You can then assign your Anova object to the x parameter and you can assign your grouping variable to the which argument. The which argument needs to be the exact same grouping variable as specified in your Anova object.

Instructions

100 XP
  • Use the pairwise.t.test() function to follow up your Anova analyses and print the output to the console. Make sure to specify the duration variable to x argument and the genre variable to the g argument. Also make sure to use a Bonferroni correction. All variables are available in the song_data dataframe.
  • Do a Tukey to follow up your Anova. Your Anova object is availabe under the name fit_aov. Set the which argument to the character argument "song_data$genre" and print the output to the console.