Three-Way ANOVA
Calculator
Learn More
Three-Way ANOVA
Definition
Three-Way ANOVA (Analysis of Variance) examines the influence of three independent variables on a continuous dependent variable. It tests main effects and interactions between factors. It tests:
- Main effects of each factor
- Interaction effects between factors
- The three-way interaction between all three factors
Model
Where:
- = dependent variable value for the th observation in the group
- = overall mean
- = main effects of factors
- = two-way interaction effects
- = three-way interaction
- = error (residual) term
Test statistic for each factor:
Key Assumptions
Independence: Observations are independent
Normality: Residuals are normally distributed
Homogeneity: Equal variances across groups
Practical Example
Step 1: State the Data
Investigating the effects of teaching method, gender, and grade level on test scores:
- Dependent Variable: Test Score
- Factor A: Teaching Method (Lecture, GroupWork, Mixed)
- Factor B: Gender (Male, Female)
- Factor C: Grade Level (9th, 10th)
- Sample Size: 60 students
Teaching Method | Gender | Grade | Test Scores |
---|---|---|---|
Lecture | Male | 9th | 98 |
Lecture | Male | 9th | 84 |
Lecture | Male | 10th | 98 |
GroupWork | Male | 9th | 72 |
GroupWork | Male | 10th | 72 |
... |
For the complete dataset, please refer to the code examples below.
Step 2: State Hypotheses
Main Effects:
- : No effect of teaching method
- : No effect of gender
- : No effect of grade level
Interactions:
- : No method × gender interaction
- : No method × grade interaction
- : No gender × grade interaction
- : No three-way interaction
Step 3: ANOVA Results
Source | SS | df | MS | F | p-value |
---|---|---|---|---|---|
Method | 68 | 2 | 34.22 | 0.403 | 0.671 |
Gender | 180 | 1 | 180.27 | 2.123 | 0.152 |
Grade | 38 | 1 | 38.40 | 0.452 | 0.504 |
Method:Gender | 66 | 2 | 32.92 | 0.388 | 0.681 |
Method:Grade | 218 | 2 | 108.95 | 1.283 | 0.286 |
Gender:Grade | 4 | 1 | 4.27 | 0.050 | 0.824 |
Method:Gender:Grade | 137 | 2 | 68.52 | 0.807 | 0.452 |
Residuals | 4076 | 48 | 84.91 |
Step 4: Conclusions
- No significant main effect of Method (F(2,48) = 1.283, p = .286)
- No significant main effect of Gender (F(1,48) = 0.452, p = .504)
- No significant main effect of Grade (F(1,48) = 0.388, p = .681)
- No significant two-way interactions: Method:Gender (F(2,48) = 0.388, p = .681), Method:Grade (F(2,48) = 1.283, p = .286), Gender:Grade (F(1,48) = 0.050, p = .824)
- No significant three-way interaction between Method:Gender:Grade (F(2,48) = 0.807, p = .452)
Code Examples
R
1library(tidyverse)
2
3set.seed(42)
4
5# Data preparation
6data <- tibble(
7 Method = rep(c("Lecture", "GroupWork", "Mixed"), each = 20),
8 Gender = rep(rep(c("Male", "Female"), each = 10), 3),
9 Grade = rep(c("9th", "10th"), each = 5, times = 6),
10 Score = round(runif(60, min = 70, max = 100))
11)
12
13# Run 3-way ANOVA
14model <- aov(Score ~ Method * Gender * Grade, data = data)
15summary(model)
Python
1import pandas as pd
2import numpy as np
3import statsmodels.api as sm
4from statsmodels.stats.anova import anova_lm
5
6np.random.seed(42)
7
8# Create example data
9data = pd.DataFrame({
10 'Method': np.repeat(['Lecture', 'GroupWork', 'Mixed'], 20),
11 'Gender': np.tile(np.repeat(['Male', 'Female'], 10), 3),
12 'Grade': np.tile(np.repeat(['9th', '10th'], 5), 6),
13 'Score': np.random.randint(70, 100, 60)
14})
15
16# Fit the model
17model = sm.OLS.from_formula('Score ~ Method * Gender * Grade', data=data).fit()
18
19# Get ANOVA table
20anova_table = anova_lm(model, typ=3)
21print(anova_table)
Post-Hoc Analysis
For significant effects:
- Tukey HSD: Compare all pairs of levels
- Simple Effects Analysis: Examine one factor at levels of others
Related Calculators
One-Way ANOVA Calculator
Two-Way ANOVA Calculator
Independent T-Test Calculator
Repeated Measures ANOVA Calculator
Help us improve
Found an error or have a suggestion? Let us know!