StatsCalculators.com

Three-way ANOVA

This Three-Way ANOVA Calculator helps you analyze the effects of three independent variables (factors) on a dependent variable. It calculates main effects and interaction effects between factors, helping you understand how multiple categorical variables influence your outcome measure. For example, you can analyze how teaching method, student gender, and grade level affect test scores, or how temperature, pressure, and catalyst type affect chemical reaction yields. Click here to populate the sample data for a quick example.

Calculator

1. Load Your Data

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
library(tidyverse)

set.seed(42)

# Data preparation
data <- tibble(
  Method = rep(c("Lecture", "GroupWork", "Mixed"), each = 20),
  Gender = rep(rep(c("Male", "Female"), each = 10), 3),
  Grade = rep(c("9th", "10th"), each = 5, times = 6),
  Score = round(runif(60, min = 70, max = 100))
)

# Run 3-way ANOVA
model <- aov(Score ~ Method * Gender * Grade, data = data)
summary(model)
Python
import pandas as pd
import numpy as np
import statsmodels.api as sm
from statsmodels.stats.anova import anova_lm

np.random.seed(42)

# Create example data
data = pd.DataFrame({
    'Method': np.repeat(['Lecture', 'GroupWork', 'Mixed'], 20),
    'Gender': np.tile(np.repeat(['Male', 'Female'], 10), 3),
    'Grade': np.tile(np.repeat(['9th', '10th'], 5), 6),
    'Score': np.random.randint(70, 100, 60)
})

# Fit the model
model = sm.OLS.from_formula('Score ~ Method * Gender * Grade', data=data).fit()

# Get ANOVA table
anova_table = anova_lm(model, typ=3)
print(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

Verification

Related Calculators

Help us improve

Found an error or have a suggestion? Let us know!