A two-way ANOVA (“analysis of variance”) is used to determine whether or not there is a statistically significant difference between the means of three or more independent groups that have been split on two variables (sometimes called “factors”).
This tutorial explains the following:
- When to use a two-way ANOVA.
- The assumptions that should be met to perform a two-way ANOVA.
- An example of how to perform a two-way ANOVA.
When to Use a Two-Way ANOVA
You should use a two-way ANOVA when you’d like to know how two factors affect a response variable and whether or not there is an interaction effect between the two factors on the response variable.
For example, suppose a botanist wants to explore how sunlight exposure and watering frequency affect plant growth. She plants 40 seeds and lets them grow for two months under different conditions for sunlight exposure and watering frequency. After two months, she records the height of each plant.
In this case, we have the following variables:
- Response variable: plant growth
- Factors: sunlight exposure, watering frequency
And we would like to answer the following questions:
- Does sunlight exposure affect plant growth?
- Does watering frequency affect plant growth?
- Is there an interaction effect between sunlight exposure and watering frequency? (e.g. the effect that sunlight exposure has on the plants is dependent on watering frequency)
We would use a two-way ANOVA for this analysis because we have two factors. If instead we wanted to know how only watering frequency affected plant growth, we would use a one-way ANOVA since we would only be working with one factor.
Two-Way ANOVA Assumptions
For the results of a two-way ANOVA to be valid, the following assumptions should be met:
1. Normality – The response variable is approximately normally distributed for each group.
2. Equal Variances – The variances for each group should be roughly equal.
3. Independence – The observations in each group are independent of each other and the observations within groups were obtained by a random sample.
Two-Way ANOVA: Example
A botanist wants to know whether or not plant growth is influenced by sunlight exposure and watering frequency. She plants 40 seeds and lets them grow for two months under different conditions for sunlight exposure and watering frequency. After two months, she records the height of each plant. The results are shown below:

In the table above, we see that there were five plants grown under each combination of conditions.
For example, there were five plants grown with daily watering and no sunlight and their heights after two months were 4.8 inches, 4.4 inches, 3.2 inches, 3.9 inches, and 4.4 inches:

She performs a two-way ANOVA in Excel and ends up with the following output:

The last table shows the result of the two-way ANOVA. We can observe the following:
- The p-value for the interaction between watering frequency and sunlight exposure was 0.310898. This is not statistically significant at alpha level 0.05.
- The p-value for watering frequency was 0.975975. This is not statistically significant at alpha level 0.05.
- The p-value for sunlight exposure was 3.9E-8 (0.000000039). This is statistically significant at alpha level 0.05.
These results indicate that sunlight exposure is the only factor that has a statistically significant effect on plant height.
And because there is no interaction effect, the effect of sunlight exposure is consistent across each level of watering frequency.
That is, whether a plant is watered daily or weekly has no impact on how sunlight exposure affects a plant.
Additional Resources
The following articles explain how to perform a two-way ANOVA using different statistical software:
How to Perform a Two-Way ANOVA in Excel
How to Perform a Two-Way ANOVA in R
How to Perform a Two-Way ANOVA in Python
How to Perform a Two-Way ANOVA in SPSS
How to Perform a Two-Way ANOVA in Stata
how do u calculate Cronbach alpha from that?
This was very helpful. Thankyou
how we run 5 way ANOVA?
two way anova (factorial analysics). you just write two way anova( analysics of variance)
It’s helpful
It’s too helping
so helpful
Thank you for your feedback jonathan!
Thanks for this
How would calculate the eta square in this case?
Great question! Eta squared (η²) is a **measure of effect size** used in ANOVA, including **Two-Way ANOVA**, to indicate the proportion of variance in the dependent variable that is attributable to a factor (independent variable) or interaction between factors.
—
### 📘 **Definition: Eta Squared (η²)**
In a **Two-Way ANOVA**, you often calculate **eta squared** for:
– Factor A (main effect)
– Factor B (main effect)
– A × B (interaction effect)
The formula is the same for each:
\[
\eta^2 = \frac{SS_{\text{effect}}}{SS_{\text{total}}}
\]
Where:
– \( SS_{\text{effect}} \) is the **sum of squares** for the factor or interaction
– \( SS_{\text{total}} \) is the **total sum of squares**
—
### 🧮 **Step-by-Step: How to Calculate η²**
Assume you have this ANOVA summary:
| Source | SS (Sum of Squares) | df | MS (Mean Square) | F | p |
|—————-|———————|—-|——————|——-|——-|
| Factor A | 40 | 1 | 40 | 10 | 0.003 |
| Factor B | 20 | 1 | 20 | 5 | 0.04 |
| A × B | 10 | 1 | 10 | 2.5 | 0.12 |
| Error | 80 | 20 | 4 | | |
| **Total** | **150** | 23 | | | |
Now compute **eta squared**:
– \( \eta^2_A = \frac{40}{150} = 0.267 \)
– \( \eta^2_B = \frac{20}{150} = 0.133 \)
– \( \eta^2_{A \times B} = \frac{10}{150} = 0.067 \)
—
### ✅ **Interpretation (Cohen’s guidelines):**
– **Small** effect: η² ≈ 0.01
– **Medium** effect: η² ≈ 0.06
– **Large** effect: η² ≈ 0.14
So in the example:
– Factor A has a **large effect**
– Factor B has a **medium effect**
– The interaction A × B has a **small effect**
—
nice Zach brother, your way of elaboration is so simple and easy to understand. it enables to learn statistics to all those who lack access to privileged universities and online resources due to financial or institutionl constraints. your efforts are really wonderful in spreading knowledge to betterment of the world and mankind. Support from India.
Thank you Balram for your kind words and feedback! We greatly appreciate your support!