Get startedGet started for free

Interactive effects

1. Interactive effects

Now that we are comfortable with the basics of using the ANOVA, we're going to add a little complexity to this method. ANOVA is also capable of revealing interactive effects.

2. Additive model

Until now, when we talked about a factor having an effect, we were implicitly talking about additive models only. An additive model describes a situation where the effect of each factor on our dependent variable is thought about in terms of adding or subtracting from the results observed. Let's use our potato production example to demonstrate this. Here we have two fertilizers and two varieties and are interested in potato production per hectare. For additive effects, changing each factor will change the mean value of production by 4 tons. Though the values of production, the dependent variable, are a result of both factors, the effect of each factor is the same, irrespective of the other.

3. Interactive effects

This need not be the case, however. Often, interactive effects are also present. Here, we have a situation where the two factors only have an effect if both are changed. Fertilizer D is only better than Fertilizer C when treating Rooster potatoes.

4. Interactive effects

Here, we have a case where the effect of variety is inverted depending on the type of fertilizer. Fertilizer E gives higher production for the Rooster variety, while Fertilizer F increases production for the Records variety. Other types of interactive effects exist. In both cases, if we looked at each factor separately we would not be able to make sense of the result. One of the strengths of ANOVA is that it examines multiple factors simultaneously, making it well suited to uncover these kinds of interactive effects. In fact, ANOVA with interaction is a normal standard ANOVA.

5. Implementing ANOVA with interactive effects

To implement an ANOVA with an interactive effect, we simply need to change the formula. To specify an interactive effect between two variables, we use variable 1 colon variable 2. As before, we specify the formula as a string, pass it and our DataFrame to the ols function, and output the table after running the anova underscore lm function. Note that the output table has one extra row, with the possible interactive effect considered as a third variable.

6. Example 1

Let's consider this example, where it seems that both factors need to change for production, our dependent variable, to be affected.

7. Interactive effect

This is the AOV table that the underlying data yields. As you can see, all three variables are statistically significant.

8. Example 2

And when we look at a simpler example? For this case, seen previously, intuition would indicate that the relationships may be additive, with each variable acting separately from the other.

9. No interactive effect

And that intuition is correct. Both factors have significant effects, but no interactive effect is present.

10. Beyond 2-way ANOVA

We have considered ANOVA in cases where we're interested in one or two factors. For a two-factor ANOVA, we end up considering three variables, two factors and one interactive effect, with one p-value for each of these. It's possible to go beyond this and consider 3 or more factors. Let's say we add season as a third factor to our example. With 3 factors, we end up considering 7 variables in total, our three factors plus four different combinations of these factors as interactions. As you can see, adding more factors can quickly become very unwieldy. We'll stick with one and two way ANOVA for this course, but it's useful to know that they exist.

11. Let's practice!

Let's practice your ANOVA skills.