Guide: Two-way ANOVA (Parametric Test)

Does pollution AND temperature have an effect on a new found (fake!) aquatic species Pollutionia vertia? How do I even test for this interaction? What should I do to test for this interaction? A two-way ANOVA!

A two-way ANOVA is a statistical method that is used to analyze the influence of two categorical independent variables on a continuous dependent variable. It assesses to see if there are significant differences between the means of the dependent variable across the different groups/categories being studied. It also assesses to see if there is an interaction effect between the two independent variables. How? Let’s take a look!

Prompt: Fish4Life, a local fisherman group in your area, has approached your company and asked to run a study on aquatic vertebrates and the impact on pollution and temperature levels on their growth. They are particularly interested in the species Pollutionia vertia, a new species of fish that is near threatened. To control for various outside variables, you decide to run an experiment in a laboratory setting. You randomly choose 50 individuals to use in your study. You record the temperature (high, low), pollution level (high, moderate, low), and the size of the fish species. After the study, you give the fish a miracle supplement to cleanse them of any negative effects pollution and temperature may have had and then release them into the wild. Below is a snippet of the dataset you collected:

temperature pollution_level species_growth
low high 10.17
high high 9.40
high high 10.18
high high 6.02
low moderate 9.56
low high 10.71
low low 12.96
high low 8.96
high low 8.38

Determine if there is a significant interaction between temperature and pollution on the growth of Pollutionia vertia.

Independent categorical variables are: temperature and pollution_level
Dependent continuous variable is the species_growth

Assumptions of Two-way ANOVA
The assumptions of a two-way ANOVA are similar to the one-way ANOVA. Let’s recap:

1. Independence
Observations must be independent of one another. For this example, we know it is in laboratory conditions, and for simplicity’s sake we can say that the species were all kept in separate tanks and fed the same amount of food. So in theory, they should have uniform growth (science usually has other plans though…).
Additionally, your errors or residuals should be independent of each other. This is also related to your experimental setup, and we can say that they are for this example.

2. Normality
The two-way ANOVA requires normality between the residuals (the differences between the observed and predicted values). Meaning that these differences should be approximately normally distributed for each combination of levels for the independent variables. Let’s test it:

Prompt: run a normality test on each combination of categorical variables and then a levenes test please on this dataset (levene’s test results in 3).


It passes all normality tests!

3. Homogeneity of Variance (Homoscedasticity)
The variance of the dependent variable should be equal across all combinations of levels of the independent variables. This is important to test for because unequal variances can inflate Type I error rates (false-positive result), which can affect the power of the analysis.
|394x106.4379695504063
Our dataset passes this as well!

4. No significant interaction
This assumption relates to the interaction effect between the two independent variables. It just makes sure that the effect of one independent variable on the dependent variable is consistent across all levels of the other independent variable. This will be determined when you run the two-way ANOVA: if the p-value is less than 0.05 (also referred to as alpha or α) it indicates that there is a significant interaction.

Let’s perform the test!

Question 1: does temperature and/or pollution level affect fish growth?

Prompt 1: can you run a two-way anova to test to see if temperature and pollution_level has a significant effect on species_growth?

Watch this magic:

NICE! Julius has run a lovely two-way ANOVA for us. I’ll break down the results for us:

Temperature by itself has a significant effect on the growth of our species (F(1,44) = 4.820, p = 0.033). However, pollution level and the interaction between the two (temperature x pollution_level) is not considered statistically significant (Pollution: F(2,44) = 1.257, p = 0.295; Interaction: F(2,44) = 2.105, p = 0.134).

What now? Julius gave me a prompt on “explore the relationship between temperature and species growth in more detail”. So, me being the nosey little scientist I am, I used that prompt to examine this finding more in detail:

Prompt: explore the relationship between temperature and species growth in more detail


The first thing Julius provides me with is a graph (who would have thought!). This bargraph highlights the differences we detected via the two-way ANOVA, comparing species growth between two different temperatures. Pollutionia vertia seems to grow larger at lower temperatures, in comparison to the individuals who were exposed to high temperatures.

Julius then goes into performing a t-test to further compare these differences found between temperature and species growth. The T-test indicated statistically significant results (t(48) = 2.323, p = 0.024).

Recap of Findings
We found that only temperature, specifically cooler temperatures, influences the growth of the Pollutia vertia species (F(1,44) = 4.820, p = 0.033). We also found that, pollution level and the interaction between the two (temperature x pollution_level) is not considered statistically significant (Pollution: F(2,44) = 1.257, p = 0.295; Interaction: F(2,44) = 2.105, p = 0.134).

We then used a t-test to confirm the relationship between temperature and species growth. The t-test further confirmed our two-way ANOVA results.

Thanks for joining me in another statistical analysis journey!

Keywords: AI statistics, AI statistical analysis, two-way anova, interaction effect, normality test, homoscedasticity

3 Likes

Thank you for creating this guide and sharing valuable information. It’s intriguing to see regression analysis using OLS, a method commonly applied to continuous variables, despite the use of a categorical independent variable. However, I noticed there was no mention of creating dummy variables, which are typically utilized in such cases.

4 Likes

Hi Philip!

Thanks for the compliment! You are absolutely correct for the dummy variable. You need to recode the categorical independent variable in order for it to run correctly.

I will go more in depth on how to run a linear regression analysis explaining everything in a future guide.

3 Likes

Wow, thanks for this in-depth analysis of the two-way ANOVA! I really liked how you recapped your findings at the end. It added a nice touch! Also, love the fake species name XD

1 Like

Hello,
Thank you for the post.
How would you rate my understanding of two way anova, based on the followings out of 5 ?

Hypotheses for Two-Way ANOVA

In a two-way ANOVA, we typically set up hypotheses for each main effect and their interaction. Here are the hypotheses for this dataset:

  1. Fertilizer Type (A)
  • Null Hypothesis (H0A): The mean height of plants is the same across different fertilizer types.
  • Alternative Hypothesis (H1A): The mean height of plants differs between at least two fertilizer types.
  1. Watering Frequency (B)
  • Null Hypothesis (H0B): The mean height of plants is the same across different watering frequencies.
  • Alternative Hypothesis (H1B): The mean height of plants differs between at least two watering frequencies.
  1. Interaction of Fertilizer Type and Watering Frequency (AxB)
  • Null Hypothesis (H0AB): There is no interaction between fertilizer type and watering frequency on plant height.
  • Alternative Hypothesis (H1AB): There is an interaction between fertilizer type and watering frequency affecting plant height.
1 Like

Hi!

You seem to have a solid grasp on the idea of creating null hypotheses and alterative hypotheses for an example with fertilizer type and watering frequency on plant height. Based on the information you have given, I would give you a 5/5. Good job :slight_smile:

2 Likes