Get startedGet started for free

Two-way ANOVA with interactive effects

Once again, you're going to look at our dataset of Olympic athletes. As in previous exercises, you'll be looking at the variation in athlete Weight. You're going to look at athletes of either Sex competing in one of two Events: the 100 meter and 10,000 meter run. Have a look at these data in the boxplots below.

Density plot of athlete weight in relation to sex and event

This dataset is provided in your workspace as athletes. An ANOVA will allow you to work out which of these variables affect Weight and whether an interactive effect is present. pandas, statsmodels, and plotnine have been loaded into the workspace as pd, sm, and p9, respectively.

This exercise is part of the course

Performing Experiments in Python

View Course

Exercise instructions

  • Perform a two-way ANOVA to test whether Sex, Event, or the interaction between the two has a significant effect on Weight.
  • Using anova_lm() on your model, extract and print the table of results produced by your ANOVA.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Run the ANOVA
model = sm.api.formula.ols('Weight ~ ____ + ____ + ____:____', data = ____).fit()

# Extract our table
aov_table = sm.api.stats.anova_lm(____, typ=2)

# Print the table
print(____)
Edit and Run Code