Skip to main content
Stats for Scholars
Concepts Decision Tree Reporting Calculators Blog Software Cheat Sheets
Concepts Decision Tree Reporting Calculators Blog Software Cheat Sheets
Home Concepts Two-Way (Factorial) ANOVA

Descriptive Statistics

  • Descriptive Statistics

Inferential Statistics

  • Chi-Square Test of Independence
  • Independent Samples t-Test
  • Kruskal-Wallis H Test
  • Logistic Regression
  • Mann-Whitney U Test
  • Multiple Linear Regression
  • One-Way ANOVA
  • Paired Samples t-Test
  • Pearson Correlation
  • Repeated Measures ANOVA
  • Simple Linear Regression
  • Two-Way (Factorial) ANOVA
  • Wilcoxon Signed-Rank Test

Effect Size & Power

  • Effect Size
  • Sample Size Determination
  • Statistical Power & Power Analysis

Reliability & Validity

  • Cronbach's Alpha
  • Inter-Rater Reliability

Two-Way (Factorial) ANOVA

intermediate Inferential Statistics

Two-Way ANOVA

Purpose
Tests the main effects of two categorical independent variables and their interaction on a continuous dependent variable.
When to Use
When you have one continuous dependent variable and two categorical independent variables (factors) and want to test whether each factor has an effect and whether the factors interact.
Data Type
Continuous (interval or ratio) dependent variable; two categorical independent variables (factors)
Key Assumptions
Independence of observations, approximately normal distributions within each cell, homogeneity of variances across all cells (tested with Levene's test).
Tools
Effect Size Calculator on Subthesis →

What Is a Two-Way ANOVA?

A two-way ANOVA (also called a factorial ANOVA) tests the effects of two categorical independent variables (called factors) on a continuous dependent variable. It simultaneously answers three questions:

  1. Main effect of Factor A: Does the dependent variable differ across the levels of Factor A, averaging over Factor B?
  2. Main effect of Factor B: Does the dependent variable differ across the levels of Factor B, averaging over Factor A?
  3. Interaction effect (A x B): Does the effect of Factor A depend on the level of Factor B (and vice versa)?

The interaction effect is what makes the two-way ANOVA uniquely powerful. It allows you to detect situations where the combination of two factors produces an outcome that neither factor alone would predict.

Example: Suppose a new drug lowers blood pressure in young adults but has no effect in older adults. Neither age alone nor drug alone tells the whole story — you need the interaction to understand the pattern.

When to Use It

Use a two-way ANOVA when:

  • You have one continuous dependent variable (e.g., exam scores, reaction time, sales revenue)
  • You have two categorical independent variables (e.g., teaching method and class size, drug type and dosage level)
  • The groups are independent (different participants in each cell of the design)

Examples:

  • Teaching method (lecture vs. active learning) x class size (small vs. large) on exam scores
  • Gender (male vs. female) x treatment (drug vs. placebo) on symptom reduction
  • Advertising type (humor vs. emotional vs. informational) x medium (TV vs. social media) on brand recall

Design notation: A 2 x 3 ANOVA has two levels of Factor A and three levels of Factor B, producing 6 cells. A 2 x 2 design has four cells and is the simplest factorial design.

Understanding Interaction Effects

The interaction is often the most important finding in a factorial ANOVA. An interaction means the effect of one factor changes depending on the level of the other factor.

No interaction (additive effects): The lines in an interaction plot are roughly parallel. Active learning is better than lecture regardless of class size, and the advantage is about the same in both small and large classes.

Interaction present: The lines in an interaction plot cross or diverge. Active learning might outperform lecture in small classes but show little advantage in large classes. The effect of teaching method depends on class size.

When the interaction is significant, interpret it first. The main effects can be misleading because averaging across levels of the other factor hides the conditional pattern. Report simple effects — the effect of Factor A at each level of Factor B — rather than relying on marginal means alone.

Assumptions

  1. Independence of observations. Each participant appears in only one cell of the design.

  2. Normality. The dependent variable should be approximately normally distributed within each cell. The two-way ANOVA is robust to moderate violations when cell sizes are equal and at least 15-20 per cell.

  3. Homogeneity of variances. The variances should be roughly equal across all cells of the design. Test with Levene's test. If violated, consider a more robust method or transform the data.

  4. No significant outliers. Extreme values within cells can distort the F-tests. Check boxplots within each cell.

Formula

Decomposing Variance

The total variance is partitioned into four components:

SStotal=SSA+SSB+SSA×B+SSwithinSS_{total} = SS_A + SS_B + SS_{A \times B} + SS_{within} SStotal​=SSA​+SSB​+SSA×B​+SSwithin​

Main effect of Factor A:

SSA=∑j=1abnc(Xˉj⋅−Xˉgrand)2SS_A = \sum_{j=1}^{a} bn_c (\bar{X}_{j\cdot} - \bar{X}_{grand})^2 SSA​=j=1∑a​bnc​(Xˉj⋅​−Xˉgrand​)2

Main effect of Factor B:

SSB=∑k=1banc(Xˉ⋅k−Xˉgrand)2SS_B = \sum_{k=1}^{b} an_c (\bar{X}_{\cdot k} - \bar{X}_{grand})^2 SSB​=k=1∑b​anc​(Xˉ⋅k​−Xˉgrand​)2

Interaction effect:

SSA×B=nc∑j=1a∑k=1b(Xˉjk−Xˉj⋅−Xˉ⋅k+Xˉgrand)2SS_{A \times B} = n_c \sum_{j=1}^{a}\sum_{k=1}^{b}(\bar{X}_{jk} - \bar{X}_{j\cdot} - \bar{X}_{\cdot k} + \bar{X}_{grand})^2 SSA×B​=nc​j=1∑a​k=1∑b​(Xˉjk​−Xˉj⋅​−Xˉ⋅k​+Xˉgrand​)2

Within-groups (error):

SSwithin=∑j=1a∑k=1b∑i=1nc(Xijk−Xˉjk)2SS_{within} = \sum_{j=1}^{a}\sum_{k=1}^{b}\sum_{i=1}^{n_c}(X_{ijk} - \bar{X}_{jk})^2 SSwithin​=j=1∑a​k=1∑b​i=1∑nc​​(Xijk​−Xˉjk​)2

Where aaa = number of levels of Factor A, bbb = number of levels of Factor B, ncn_cnc​ = number of participants per cell.

Mean Squares and F-Ratios

Each effect has its own F-test:

FA=MSAMSwithin=SSA/(a−1)SSwithin/(N−ab)F_A = \frac{MS_A}{MS_{within}} = \frac{SS_A / (a-1)}{SS_{within} / (N - ab)} FA​=MSwithin​MSA​​=SSwithin​/(N−ab)SSA​/(a−1)​

FB=MSBMSwithin=SSB/(b−1)SSwithin/(N−ab)F_B = \frac{MS_B}{MS_{within}} = \frac{SS_B / (b-1)}{SS_{within} / (N - ab)} FB​=MSwithin​MSB​​=SSwithin​/(N−ab)SSB​/(b−1)​

FA×B=MSA×BMSwithin=SSA×B/(a−1)(b−1)SSwithin/(N−ab)F_{A \times B} = \frac{MS_{A \times B}}{MS_{within}} = \frac{SS_{A \times B} / (a-1)(b-1)}{SS_{within} / (N - ab)} FA×B​=MSwithin​MSA×B​​=SSwithin​/(N−ab)SSA×B​/(a−1)(b−1)​

Effect Size: Partial Eta-Squared

For each effect:

ηp2=SSeffectSSeffect+SSwithin\eta_p^2 = \frac{SS_{effect}}{SS_{effect} + SS_{within}} ηp2​=SSeffect​+SSwithin​SSeffect​​

ηp2\eta_p^2ηp2​ Interpretation
.01 Small
.06 Medium
.14 Large

Worked Example

Scenario: An educational researcher investigates the effects of teaching method (Lecture vs. Active Learning) and class size (Small: 20 students vs. Large: 80 students) on final exam scores. This is a 2 x 2 between-subjects factorial design with 8 students per cell (N=32N = 32N=32).

Cell means and standard deviations:

Small Class Large Class Marginal Mean
Lecture MMM = 72, SDSDSD = 6 MMM = 70, SDSDSD = 7 71.0
Active Learning MMM = 85, SDSDSD = 5 MMM = 74, SDSDSD = 6 79.5
Marginal Mean 78.5 72.0 Xˉgrand\bar{X}_{grand}Xˉgrand​ = 75.25

Step 1: State the hypotheses.

  • Main effect of Method: H0H_0H0​: μlecture=μactive\mu_{\text{lecture}} = \mu_{\text{active}}μlecture​=μactive​
  • Main effect of Class Size: H0H_0H0​: μsmall=μlarge\mu_{\text{small}} = \mu_{\text{large}}μsmall​=μlarge​
  • Interaction: H0H_0H0​: The effect of teaching method does not depend on class size

Step 2: Calculate sums of squares.

Each cell has nc=8n_c = 8nc​=8. Factor A (Method) has a=2a = 2a=2 levels, Factor B (Class Size) has b=2b = 2b=2 levels.

SSASS_ASSA​ (Method):

SSA=bnc∑j=1a(Xˉj⋅−Xˉgrand)2=2×8×[(71.0−75.25)2+(79.5−75.25)2]SS_A = bn_c \sum_{j=1}^{a}(\bar{X}_{j\cdot} - \bar{X}_{grand})^2 = 2 \times 8 \times [(71.0 - 75.25)^2 + (79.5 - 75.25)^2] SSA​=bnc​j=1∑a​(Xˉj⋅​−Xˉgrand​)2=2×8×[(71.0−75.25)2+(79.5−75.25)2]

=16×[18.0625+18.0625]=16×36.125=578.0= 16 \times [18.0625 + 18.0625] = 16 \times 36.125 = 578.0 =16×[18.0625+18.0625]=16×36.125=578.0

SSBSS_BSSB​ (Class Size):

SSB=anc∑k=1b(Xˉ⋅k−Xˉgrand)2=2×8×[(78.5−75.25)2+(72.0−75.25)2]SS_B = an_c \sum_{k=1}^{b}(\bar{X}_{\cdot k} - \bar{X}_{grand})^2 = 2 \times 8 \times [(78.5 - 75.25)^2 + (72.0 - 75.25)^2] SSB​=anc​k=1∑b​(Xˉ⋅k​−Xˉgrand​)2=2×8×[(78.5−75.25)2+(72.0−75.25)2]

=16×[10.5625+10.5625]=16×21.125=338.0= 16 \times [10.5625 + 10.5625] = 16 \times 21.125 = 338.0 =16×[10.5625+10.5625]=16×21.125=338.0

SSA×BSS_{A \times B}SSA×B​ (Interaction):

SSA×B=nc∑j∑k(Xˉjk−Xˉj⋅−Xˉ⋅k+Xˉgrand)2SS_{A \times B} = n_c \sum_{j}\sum_{k}(\bar{X}_{jk} - \bar{X}_{j\cdot} - \bar{X}_{\cdot k} + \bar{X}_{grand})^2 SSA×B​=nc​j∑​k∑​(Xˉjk​−Xˉj⋅​−Xˉ⋅k​+Xˉgrand​)2

Compute the residual for each cell:

  • Lecture, Small: 72−71.0−78.5+75.25=−2.2572 - 71.0 - 78.5 + 75.25 = -2.2572−71.0−78.5+75.25=−2.25
  • Lecture, Large: 70−71.0−72.0+75.25=2.2570 - 71.0 - 72.0 + 75.25 = 2.2570−71.0−72.0+75.25=2.25
  • Active, Small: 85−79.5−78.5+75.25=2.2585 - 79.5 - 78.5 + 75.25 = 2.2585−79.5−78.5+75.25=2.25
  • Active, Large: 74−79.5−72.0+75.25=−2.2574 - 79.5 - 72.0 + 75.25 = -2.2574−79.5−72.0+75.25=−2.25

SSA×B=8×[(−2.25)2+(2.25)2+(2.25)2+(−2.25)2]=8×4×5.0625=162.0SS_{A \times B} = 8 \times [(-2.25)^2 + (2.25)^2 + (2.25)^2 + (-2.25)^2] = 8 \times 4 \times 5.0625 = 162.0 SSA×B​=8×[(−2.25)2+(2.25)2+(2.25)2+(−2.25)2]=8×4×5.0625=162.0

SSwithinSS_{within}SSwithin​ (Error):

Using SSwithin=∑(nc−1)×sj2SS_{within} = \sum (n_c - 1) \times s_j^2SSwithin​=∑(nc​−1)×sj2​ for each cell:

SSwithin=7(36)+7(49)+7(25)+7(36)=252+343+175+252=1022SS_{within} = 7(36) + 7(49) + 7(25) + 7(36) = 252 + 343 + 175 + 252 = 1022 SSwithin​=7(36)+7(49)+7(25)+7(36)=252+343+175+252=1022

Step 3: Calculate mean squares and F-ratios.

Source SS df MS F
Method (A) 578.0 1 578.0 15.84
Class Size (B) 338.0 1 338.0 9.26
A x B 162.0 1 162.0 4.44
Within (Error) 1022.0 28 36.5
Total 2100.0 31

MSwithin=1022/28=36.5MS_{within} = 1022 / 28 = 36.5MSwithin​=1022/28=36.5

Step 4: Determine p-values.

Using the F-distribution with df1=1df_1 = 1df1​=1, df2=28df_2 = 28df2​=28:

  • Method: F(1,28)=15.84F(1, 28) = 15.84F(1,28)=15.84, p<.001p < .001p<.001
  • Class Size: F(1,28)=9.26F(1, 28) = 9.26F(1,28)=9.26, p=.005p = .005p=.005
  • Interaction: F(1,28)=4.44F(1, 28) = 4.44F(1,28)=4.44, p=.044p = .044p=.044

All three effects are statistically significant.

Step 5: Calculate effect sizes (partial eta-squared).

ηp2(Method)=578578+1022=.361\eta_p^2(\text{Method}) = \frac{578}{578 + 1022} = .361 ηp2​(Method)=578+1022578​=.361

ηp2(Class Size)=338338+1022=.249\eta_p^2(\text{Class Size}) = \frac{338}{338 + 1022} = .249 ηp2​(Class Size)=338+1022338​=.249

ηp2(Interaction)=162162+1022=.137\eta_p^2(\text{Interaction}) = \frac{162}{162 + 1022} = .137 ηp2​(Interaction)=162+1022162​=.137

Step 6: Interpret the interaction.

Because the interaction is significant, we examine the simple effects:

  • In small classes: Active learning (M=85M = 85M=85) outperformed lecture (M=72M = 72M=72) by 13 points
  • In large classes: Active learning (M=74M = 74M=74) outperformed lecture (M=70M = 70M=70) by only 4 points

The advantage of active learning shrinks considerably in large classes. This is the interaction — teaching method and class size jointly influence exam scores in a way that cannot be explained by either factor alone.

Interpretation

The two-way ANOVA revealed significant main effects and a significant interaction:

  • Main effect of teaching method: Active learning (M=79.5M = 79.5M=79.5) produced significantly higher exam scores than lecture (M=71.0M = 71.0M=71.0), F(1,28)=15.84F(1, 28) = 15.84F(1,28)=15.84, p<.001p < .001p<.001, ηp2=.36\eta_p^2 = .36ηp2​=.36.
  • Main effect of class size: Small classes (M=78.5M = 78.5M=78.5) produced significantly higher scores than large classes (M=72.0M = 72.0M=72.0), F(1,28)=9.26F(1, 28) = 9.26F(1,28)=9.26, p=.005p = .005p=.005, ηp2=.25\eta_p^2 = .25ηp2​=.25.
  • Interaction: The advantage of active learning over lecture was significantly larger in small classes (13 points) than in large classes (4 points), F(1,28)=4.44F(1, 28) = 4.44F(1,28)=4.44, p=.044p = .044p=.044, ηp2=.14\eta_p^2 = .14ηp2​=.14.

The interaction suggests that active learning is most effective in small class environments. In large classes, the benefit of active learning is reduced — possibly because large group sizes limit the student engagement and participation that active learning relies on.

Common Mistakes

  1. Interpreting main effects when the interaction is significant. Main effects represent average differences across levels of the other factor. When an interaction is present, these averages are misleading. Focus on simple effects instead.

  2. Ignoring unbalanced designs. When cell sizes are unequal, the sums of squares for different effects are no longer independent. Use Type III sums of squares (the default in most software) to correctly partition variance.

  3. Not plotting the interaction. An interaction plot (with one factor on the x-axis, the DV on the y-axis, and separate lines for the other factor) is essential for understanding the pattern. Non-parallel lines indicate an interaction.

  4. Confusing ordinal and disordinal interactions. In an ordinal interaction, one group is always higher but the gap changes in size (the lines do not cross). In a disordinal (crossover) interaction, the direction of the effect reverses (the lines cross). Disordinal interactions are typically more theoretically interesting.

  5. Running separate one-way ANOVAs instead. Analyzing each factor separately ignores the interaction and wastes statistical power. The two-way ANOVA tests both factors and their interaction simultaneously.

  6. Not checking assumptions within cells. Normality and homogeneity of variances must hold within each cell (combination of factor levels), not just within each level of a single factor.

How to Run It

```r # Two-way ANOVA in R model <- aov(score ~ method * class_size, data = mydata) summary(model)

Effect sizes (partial eta-squared)

library(effectsize) eta_squared(model, partial = TRUE)

Interaction plot

interaction.plot(mydata$class_size, mydata$method, mydata$score, xlab = "Class Size", ylab = "Exam Score", trace.label = "Method")

Simple effects (if interaction is significant)

library(emmeans) emm <- emmeans(model, ~ method | class_size) pairs(emm)

```python import pandas as pd import pingouin as pg from statsmodels.formula.api import ols from statsmodels.stats.anova import anova_lm # Using statsmodels (Type II SS by default) model = ols('score ~ C(method) * C(class_size)', data=df).fit() table = anova_lm(model, typ=2) print(table) # Using pingouin aov = pg.anova(dv='score', between=['method', 'class_size'], data=df) print(aov) # Interaction plot import matplotlib.pyplot as plt pd.pivot_table(df, values='score', index='class_size', columns='method').plot(marker='o') plt.ylabel('Exam Score') plt.show() ```
  1. Go to Analyze > General Linear Model > Univariate
  2. Move your dependent variable (e.g., Exam Score) into the Dependent Variable box
  3. Move both independent variables (e.g., Method and Class Size) into the Fixed Factor(s) box
  4. Click Options: check Descriptive statistics, Estimates of effect size, and Homogeneity tests
  5. Click Plots: put one factor on the Horizontal Axis and the other in Separate Lines, then click Add
  6. Click Post Hoc if any factor has 3+ levels and select Tukey
  7. Click OK

SPSS reports the Tests of Between-Subjects Effects table with F-statistics, p-values, and partial eta-squared for each main effect and the interaction. If the interaction is significant, examine the Estimated Marginal Means for simple effects.

Use the Data Analysis ToolPak (enable via File > Options > Add-ins):

  1. Go to Data > Data Analysis > Anova: Two-Factor With Replication
  2. Select the input range (data arranged with one factor in rows and the other in columns, with replicates stacked within each cell)
  3. Enter the number of Rows per sample (replicates per cell)
  4. Set alpha to 0.05
  5. Click OK

Excel produces an ANOVA summary table with SS, df, MS, F, p-value, and F-critical for both main effects and the interaction. Calculate partial eta-squared manually as SSeffect / (SSeffect + SSwithin). Excel does not produce interaction plots or post-hoc tests.

## How to Report in APA Format > A 2 x 2 between-subjects ANOVA was conducted to examine the effects of teaching method (lecture vs. active learning) and class size (small vs. large) on final exam scores. There was a significant main effect of teaching method, $F$(1, 28) = 15.84, $p$ < .001, $\eta_p^2$ = .36, with active learning ($M$ = 79.5, $SD$ = 7.7) producing higher scores than lecture ($M$ = 71.0, $SD$ = 6.5). There was also a significant main effect of class size, $F$(1, 28) = 9.26, $p$ = .005, $\eta_p^2$ = .25, with small classes ($M$ = 78.5, $SD$ = 8.4) outperforming large classes ($M$ = 72.0, $SD$ = 6.7). These main effects were qualified by a significant interaction between teaching method and class size, $F$(1, 28) = 4.44, $p$ = .044, $\eta_p^2$ = .14. Simple effects analysis revealed that active learning produced a 13-point advantage over lecture in small classes, but only a 4-point advantage in large classes, suggesting that active learning is most effective in smaller classroom settings.

Ready to calculate?

Now that you understand the concept, use the free Effect Size Calculator on Subthesis to run your own analysis.

Calculate Effect Size for Your ANOVA on Subthesis

Related Concepts

One-Way ANOVA

Learn how to conduct a one-way ANOVA to compare three or more group means, including F-ratio formulas, post-hoc tests, and effect size with eta-squared.

Effect Size

Learn what effect size is, why it matters more than p-values alone, and how to calculate and interpret Cohen's d, Hedges' g, and eta-squared for your research.

Statistical Power & Power Analysis

Learn what statistical power is, why 80% is the standard threshold, and how to conduct a power analysis to determine if your study can detect real effects.

Stats for Scholars

Statistics for Researchers, Not Statisticians

A Subthesis Resource

Learn

  • Statistical Concepts
  • Choose a Test
  • APA Reporting
  • Blog

Resources

  • Calculators
  • Cheat Sheets
  • About
  • FAQ
  • Accessibility
  • Privacy
  • Terms

© 2026 Angel Reyes / Subthesis. All rights reserved.

Privacy Policy Terms of Use