EZ Statistics

Three-Way ANOVA

Calculator

2. Select Columns & Options

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
This test is an extension of the two-way ANOVA, adding a third factor to the model.

Model

Yijkl=μ+Ai+Bj+Ck+(AB)ij+(AC)ik+(BC)jk+(ABC)ijk+ϵijklY_{ijkl} = \mu + A_i + B_j + C_k + (AB)_{ij} + (AC)_{ik} + (BC)_{jk} + (ABC)_{ijk} + \epsilon_{ijkl}

Where:

  • YijklY_{ijkl} = dependent variable value for the llth observation in the group i,j,ki,j,k
  • μ\mu = overall mean
  • Ai,Bj,CkA_i, B_j, C_k = main effects of factors A,B,CA, B, C
  • (AB)ij,(AC)ik,(BC)jk(AB)_{ij}, (AC)_{ik}, (BC)_{jk} = two-way interaction effects
  • (ABC)ijk(ABC)_{ijk} = three-way interaction
  • ϵijkl\epsilon_{ijkl} = error (residual) term

Test statistic for each factor:

F=MSFactorMSErrorF = \frac{MS_{Factor}}{MS_{Error}}

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 MethodGenderGradeTest Scores
LectureMale9th98
LectureMale9th84
LectureMale10th98
GroupWorkMale9th72
GroupWorkMale10th72
...

For the complete dataset, please refer to the code examples below.

Step 2: State Hypotheses

Main Effects:

  • H0AH_0^A: No effect of teaching method
  • H0BH_0^B: No effect of gender
  • H0CH_0^C: No effect of grade level

Interactions:

  • H0ABH_0^{AB}: No method × gender interaction
  • H0ACH_0^{AC}: No method × grade interaction
  • H0BCH_0^{BC}: No gender × grade interaction
  • H0ABCH_0^{ABC}: No three-way interaction
Step 3: ANOVA Results
SourceSSdfMSFp-value
Method68234.220.4030.671
Gender1801180.272.1230.152
Grade38138.400.4520.504
Method:Gender66232.920.3880.681
Method:Grade2182108.951.2830.286
Gender:Grade414.270.0500.824
Method:Gender:Grade137268.520.8070.452
Residuals40764884.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!