1. Learn
  2. /
  3. Courses
  4. /
  5. Inferential Statistics

Exercise

Two-way Anova (2)

To conduct a two-way Anova, we can use the exact same functions as when conducting a one-way Anova. This means that both the aov() and lm() functions will work out. When doing a two-way anova, our between-group variance is split across both groups. This essentially means that our first variable will explain a certain amount of variance and our second variable will explain a certain amount of variance.

You can use the aov() with multiple independent variables like so:

aov(dependent_variable ~ independent_variable1 + independent_variable2)

You just have to replace independent_variable1 and independent_variable2 by the names of the variables that you are working with.

Instructions

100 XP
  • For the current exercise, all our data is available in the dataframe song_data. Conduct a two-way Anova using the aov() function. Note that you can add variables to your anova by putting a + sign behind your first independent variable followed by the name of the second independent variable. Add the anova model to the variable two_way_fit
  • Call the summary function on your your two_way_fit object and print the output to the console.