Written and maintained by CASRAI Editorial Board
Last updated
Definition: What Are the Assumptions of Two-Way ANOVA?
The assumptions of two-way ANOVA are the statistical requirements that must be met for two-way factorial ANOVA (analysis of variance) to yield valid F-tests, accurate p-values, and controlled Type I error rates when assessing two categorical independent and dependent variables. A two-way ANOVA partitions variance into two main factor effects and their joint interaction. Unlike simple exploratory checks that examine the raw outcome variable across the entire sample, parametric ANOVA assumptions govern the model residuals—the random error components that remain after accounting for factor levels and interaction effects. Verifying these assumptions ensures that observed group differences reflect genuine experimental effects rather than artifacts of variance heterogeneity, residual skewness, or observation dependency.
Two-Way ANOVA Model Formula and Mathematical Symbols
The fixed-effects linear model for a balanced two-way factorial design with replication partitions each observation into systematic effects and random error:
Y_ijk = μ + α_i + β_j + (αβ)_ij + ε_ijk
Each symbol corresponds to an experimental parameter:
- Y_ijk: Continuous score for replicate k in level i of Factor A and level j of Factor B.
- μ: Grand mean across all treatment conditions.
- α_i: Main effect of level i of Factor A (i = 1, …, a), where Σ α_i = 0.
- β_j: Main effect of level j of Factor B (j = 1, …, b), where Σ β_j = 0.
- (αβ)_ij: Interaction effect between Factor A level i and Factor B level j, where Σ_i (αβ)_ij = Σ_j (αβ)_ij = 0.
- ε_ijk: Random error for replicate k (k = 1, …, r), assumed normally and independently distributed: ε_ijk ~ NID(0, σ²).
Total variation partitions additively: SS_Total = SS_A + SS_B + SS_AB + SS_Error. Under null hypotheses, test statistics follow F-distributions: F = MS_Effect / MS_Error.
Worked Example: Step-by-Step Two-Way ANOVA with Real Numbers
Consider a balanced 2 × 2 factorial experiment measuring plant growth in centimeters. Factor A is Fertilizer (Standard vs. Enriched, a = 2) and Factor B is Watering (Low vs. High, b = 2), with r = 3 independent replications per cell (total N = 12).
| Fertilizer / Watering | Low Watering (B1) | High Watering (B2) | Row Sum |
|---|---|---|---|
| Standard (A1) | 10, 12, 14 (Sum = 36, Mean = 12.00, s² = 4.00) | 18, 20, 22 (Sum = 60, Mean = 20.00, s² = 4.00) | 96 |
| Enriched (A2) | 14, 16, 18 (Sum = 48, Mean = 16.00, s² = 4.00) | 28, 30, 32 (Sum = 90, Mean = 30.00, s² = 4.00) | 138 |
| Column Sum | 84 | 150 | G = 234 |
Sums of Squares Calculations
- Grand Total G = 234; Grand Mean = 19.50 cm; Correction Factor C = 234² / 12 = 4,563.00.
- Total Variation: Σ Y² = 5,132.00; SS_Total = 5,132.00 − 4,563.00 = 569.00 (df = 11).
- Factor A: SS_A = [(96² + 138²) / 6] − 4,563.00 = 147.00 (df = 1).
- Factor B: SS_B = [(84² + 150²) / 6] − 4,563.00 = 363.00 (df = 1).
- Subcells: SS_Subcells = [(36² + 60² + 48² + 90²) / 3] − 4,563.00 = 537.00.
- Interaction: SS_AB = 537.00 − 147.00 − 363.00 = 27.00 (df = 1).
- Error: SS_Error = 569.00 − 537.00 = 32.00 (df = 8).
Residual Verification
Residuals (e_ijk = Y_ijk − Ȳ_ij) equal −2, 0, and +2 in each cell. Cell variances are identical (s² = 4.00), verifying homoscedasticity. Squared residuals sum to 32.00, matching SS_Error.
Interpretation: What the ANOVA Results Mean
The complete ANOVA table is summarized below:
| Source | SS | df | MS | F | p-value | Partial Eta-Squared (η_p²) |
|---|---|---|---|---|---|---|
| Fertilizer (A) | 147.00 | 1 | 147.00 | 36.75 | p < .001 | .82 |
| Watering (B) | 363.00 | 1 | 363.00 | 90.75 | p < .001 | .92 |
| Interaction (A × B) | 27.00 | 1 | 27.00 | 6.75 | .032 | .46 |
| Error | 32.00 | 8 | 4.00 | — | — | — |
| Total | 569.00 | 11 | — | — | — | — |
When evaluating results, apply the following decision framework:
| Check | Decision Rule | Action |
|---|---|---|
| 1. Interaction | p ≤ .05 for A × B | Analyze simple main effects; do not interpret main effects in isolation. |
| 2. Main Effects | p ≤ .05 for A or B | If interaction is non-significant, interpret marginal means directly. |
| 3. F Ratio | F = MS_Effect / MS_Error | Ratios exceeding 1.0 indicate systematic variance exceeds error variance. |
| 4. Effect Size | Partial eta-squared (η_p²) | Quantifies variance explained (.01 = small, .06 = medium, .14 = large). |
Assumptions and Common Mistakes
Valid inferences require satisfying six foundational assumptions:
1. Continuous Dependent Variable
The outcome variable must be measured on an interval or ratio scale. For ordinal data, apply proportional odds logistic regression or aligned rank transform tests.
2. Two Categorical Independent Variables
The design requires two categorical factors forming a factorial grid. In between-subjects designs, each unit belongs to one cell. If subjects are measured across multiple conditions over time (as in within-subjects vs between-subjects designs), use repeated-measures ANOVA or mixed-effects models.
3. Independence of Observations
Residuals and observations must be mutually independent (Cov(ε_ijk, ε_i’j’k’) = 0). Violations severely inflate Type I error rates. Guarantee this through randomized assignment; for clustered data, use linear mixed models.
4. Normality of Residuals
Model residuals within cells must be approximately normally distributed: ε_ijk ~ N(0, σ²). Verify using Q-Q plots and the Shapiro-Wilk test on residuals. Balanced designs with n ≥ 20 are robust to moderate skewness. For severe violations, use Box-Cox power transformations or permutation ANOVA.
5. Homogeneity of Variances (Homoscedasticity)
Residual variance must be equal across all cells: σ²_11 = σ²_12 = … = σ²_ab. Screen with residuals vs. fitted plots and median-centered Levene’s test. Balanced designs tolerate variance ratios up to 3:1. For severe heteroscedasticity, use Welch’s heteroscedastic ANOVA or robust standard errors.
6. Absence of Influential Outliers
Extreme observations distort cell means and inflate error sums of squares. Screen using Cook’s distance (D_i > 4/N) and studentized residuals (|r_i| > 3.0). Resolve data errors or apply trimmed-means robust estimation.
Common Methodological Mistakes
- Testing Normality on Pooled Raw Data: Assessing normality on the combined outcome variable rather than on model residuals causes false violation flags because differences in group means induce apparent multimodality.
- Ignoring Significant Interactions: Interpreting marginal main effects while ignoring a significant interaction masks condition-dependent moderations.
- Using Type I Sums of Squares on Unbalanced Data: In non-orthogonal designs with unequal cell sizes, sequential Type I sums of squares depend on factor entry order; use Type III sums of squares instead.
How to Report Two-Way ANOVA in APA Style
APA 7th edition format requires italicized statistical symbols (F, p, M, SD, η_p²), exact integer degrees of freedom, exact p-values to three decimal places without leading zeros, and partial eta-squared.
A 2 × 2 between-subjects analysis of variance revealed a significant main effect of fertilizer type, F(1, 8) = 36.75, p < .001, η_p² = .82, with enriched fertilizer producing higher growth (M = 23.00 cm, SD = 7.72) than standard fertilizer (M = 16.00 cm, SD = 4.47). The main effect of watering was also significant, F(1, 8) = 90.75, p < .001, η_p² = .92; high watering yielded greater growth (M = 25.00 cm, SD = 5.76) than low watering (M = 14.00 cm, SD = 2.45).
The interaction between fertilizer and watering was statistically significant, F(1, 8) = 6.75, p = .032, η_p² = .46. Follow-up simple main effects confirmed that while enriched fertilizer enhanced growth under both regimens, the increase was substantially larger under high watering (ΔM = 10.00 cm) than under low watering (ΔM = 4.00 cm).
How to Calculate and Test Assumptions in Excel, R, or Python
Conducting two-way ANOVA and verifying assumptions (comparable to procedures for two-way ANOVA in SPSS and ANOVA in Python with statsmodels) can be executed across common platforms.
1. Excel Workflow
- Arrange observations in a two-way grid where rows represent Factor A levels (grouped by sample size, r = 3) and columns represent Factor B levels.
- Navigate to Data > Data Analysis > Anova: Two-Factor With Replication.
- Select the input table including labels, set
Rows per sample: 3, verifyAlpha: 0.05, and output the summary ANOVA table.
2. R Code Snippet
library(car)
df <- data.frame(
Fertilizer = factor(rep(c("Standard", "Enriched"), each = 6)),
Watering = factor(rep(rep(c("Low", "High"), each = 3), 2)),
Growth = c(10, 12, 14, 18, 20, 22, 14, 16, 18, 28, 30, 32)
)
model <- lm(Growth ~ Fertilizer * Watering, data = df)
anova(model)
shapiro.test(residuals(model))
car::leveneTest(Growth ~ Fertilizer * Watering, data = df)
3. Python Code Snippet
import pandas as pd, statsmodels.api as sm
from statsmodels.formula.api import ols
from scipy import stats
df = pd.DataFrame({
'Fertilizer': ['Standard']*6 + ['Enriched']*6,
'Watering': ['Low']*3 + ['High']*3 + ['Low']*3 + ['High']*3,
'Growth': [10, 12, 14, 18, 20, 22, 14, 16, 18, 28, 30, 32]
})
model = ols('Growth ~ C(Fertilizer) * C(Watering)', data=df).fit()
print(sm.stats.anova_lm(model, typ=2))
print("Shapiro-Wilk:", stats.shapiro(model.resid))
grouped = [g['Growth'].values for _, g in df.groupby(['Fertilizer', 'Watering'])]
print("Levene:", stats.levene(*grouped))
Frequently Asked Questions About Two-Way ANOVA Assumptions
How to read an ANOVA table?
To read an ANOVA table, examine the interaction term first. If the interaction F test is statistically significant (p ≤ .05), factor effects are interdependent and require simple effects analysis rather than isolated marginal mean interpretations. If non-significant, evaluate main effect rows directly. Confirm that the total sum of squares equals the sum of partitioned components, and inspect the Mean Square Error (MSE) to gauge pooled unexplained within-cell variation.
Does a two-way ANOVA have two independent variables?
Yes. A two-way ANOVA requires exactly two categorical independent variables (factors), each with two or more discrete levels, evaluated against a single continuous dependent variable. A one-way ANOVA uses one factor, while designs with three factors require a three-way ANOVA.
What does the F ratio indicate in an ANOVA test?
The F ratio reflects the ratio of systematic between-group variance to unsystematic within-group error variance (F = MS_Effect / MS_Error). An F ratio near 1.0 reflects random sampling variation, whereas an F ratio substantially exceeding 1.0 indicates systematic treatment differences exceeding background error.
What are the assumptions made in an ANOVA analysis?
ANOVA requires: (1) a continuous dependent variable; (2) categorical factors; (3) independent observations; (4) normally distributed residuals; (5) homogeneity of variance; and (6) no severe influential outliers.
Sources and Methodological References
- National Institute of Standards and Technology (NIST). (2012). NIST/SEMATECH e-Handbook of Statistical Methods. Section 7.4.3: Two-Way ANOVA with Replication. https://www.itl.nist.gov/div898/handbook/prc/section4/prc437.htm
- Helsel, D. R., Hirsch, R. M., Ryberg, K. R., Archfield, S. A., and Gilroy, E. J. (2020). Statistical Methods in Water Resources. U.S. Geological Survey Techniques and Methods, book 4, chap. A3, 458 p. https://pubs.usgs.gov/tm/04/a03/tm4a3.pdf
- American Psychological Association. (2020). Publication Manual of the American Psychological Association (7th ed.). Section 6.43: Statistical and Mathematical Copy. American Psychological Association.







