Loading…

Two-Way ANOVA: Main Effects, Interaction, and ANOVA Table

For a balanced 2×3 factorial experiment with replication, how does two-way anova test factor A, factor B, and the A×B interaction using an ANOVA table and F statistics?

Subject: Statistics Chapter: Analysis of Variance Topic: One Way Anova Hypothesis Test Answer included
two-way anova two factor ANOVA factorial ANOVA interaction effect main effects ANOVA table sums of squares mean square
Accepted answer Answer included

Two-way ANOVA setup (balanced 2×3 with replication)

A two-way anova analyzes one quantitative response under two categorical factors and tests: (1) the main effect of factor A, (2) the main effect of factor B, and (3) the A×B interaction. The example below is a balanced factorial design with \(a=2\) levels of A, \(b=3\) levels of B, and \(r=3\) replicates per cell.

Context (example): Plant height under two factors

  • Factor A: Fertilizer (A1 = none, A2 = new)
  • Factor B: Light (B1 = low, B2 = medium, B3 = high)
  • Response: Height (cm)

Standard conditions: independent observations, approximately normal errors within each cell, and constant variance across cells.

Factor A \ Factor B B1 (low) B2 (medium) B3 (high)
A1 (none) 9, 10, 11 13, 14, 15 17, 18, 19
A2 (new) 11, 12, 13 18, 19, 20 21, 22, 23

Model and hypotheses

With response \(y_{ijk}\) at A level \(i\), B level \(j\), replicate \(k\), a common fixed-effects model is:

\[ y_{ijk}=\mu+\alpha_i+\beta_j+(\alpha\beta)_{ij}+\varepsilon_{ijk}, \quad \varepsilon_{ijk}\sim N(0,\sigma^2). \]

Three hypothesis tests in two-way ANOVA:

  • Main effect A: \(H_0:\alpha_1=\alpha_2=\cdots=\alpha_a=0\)
  • Main effect B: \(H_0:\beta_1=\beta_2=\cdots=\beta_b=0\)
  • Interaction A×B: \(H_0:(\alpha\beta)_{ij}=0\) for all \(i,j\)

Step 1: Cell means, marginal means, and grand mean

In a balanced design, computations are cleanly expressed using cell means \(\bar{y}_{ij\cdot}\), factor means \(\bar{y}_{i\cdot\cdot}\), \(\bar{y}_{\cdot j \cdot}\), and the grand mean \(\bar{y}_{\cdot\cdot\cdot}\).

Cell mean \(\bar{y}_{ij\cdot}\) B1 B2 B3 Row mean \(\bar{y}_{i\cdot\cdot}\)
A1 10.0 14.0 18.0 14.0
A2 12.0 19.0 22.0 17.6667
Column mean \(\bar{y}_{\cdot j \cdot}\) 11.0 16.5 20.0

Grand mean: \[ \bar{y}_{\cdot\cdot\cdot}=\frac{10+14+18+12+19+22}{6}=15.8333\ldots \]

Step 2: Sums of squares (balanced two-way ANOVA)

With \(a=2\), \(b=3\), \(r=3\), total \(N=a\cdot b\cdot r=18\).

Between-factor (main effect) sums of squares

\[ SS_A=b\cdot r \cdot \sum_{i=1}^{a}\left(\bar{y}_{i\cdot\cdot}-\bar{y}_{\cdot\cdot\cdot}\right)^2, \quad SS_B=a\cdot r \cdot \sum_{j=1}^{b}\left(\bar{y}_{\cdot j \cdot}-\bar{y}_{\cdot\cdot\cdot}\right)^2. \]

Using \(b\cdot r=9\) and \(a\cdot r=6\): \[ SS_A=60.5, \qquad SS_B=247.0. \]

Interaction sum of squares

\[ SS_{AB}=r\cdot \sum_{i=1}^{a}\sum_{j=1}^{b} \left(\bar{y}_{ij\cdot}-\bar{y}_{i\cdot\cdot}-\bar{y}_{\cdot j \cdot}+\bar{y}_{\cdot\cdot\cdot}\right)^2. \]

For this dataset: \[ SS_{AB}=7.0. \]

Error and total sums of squares

\[ SS_E=\sum_{i=1}^{a}\sum_{j=1}^{b}\sum_{k=1}^{r}\left(y_{ijk}-\bar{y}_{ij\cdot}\right)^2, \qquad SS_T=SS_A+SS_B+SS_{AB}+SS_E. \]

Each cell \((9,10,11)\), \((13,14,15)\), … has within-cell squared deviations summing to 2, so \[ SS_E=6\cdot 2=12, \qquad SS_T=60.5+247.0+7.0+12.0=326.5. \]

Step 3: Degrees of freedom

\[ df_A=a-1=1,\quad df_B=b-1=2,\quad df_{AB}=(a-1)(b-1)=2,\quad df_E=a\cdot b\cdot (r-1)=12,\quad df_T=N-1=17. \]

Step 4: ANOVA table and F tests

Mean squares are \(MS=\dfrac{SS}{df}\). Each effect is tested by \(F=\dfrac{MS_{\text{effect}}}{MS_E}\).

Source SS df MS F p-value (approx.)
Factor A 60.5 1 60.5 60.5 < 0.001
Factor B 247.0 2 123.5 123.5 < 0.001
Interaction A×B 7.0 2 3.5 3.5 0.064
Error 12.0 12 1.0
Total 326.5 17
\(\alpha=0.05\) \(MS_E=1.0\) \(F_A=60.5\) \(F_B=123.5\) \(F_{AB}=3.5\)

Decisions at \(\alpha=0.05\):

  • Factor A: reject \(H_0\) (strong evidence of an A main effect).
  • Factor B: reject \(H_0\) (strong evidence of a B main effect).
  • Interaction A×B: do not reject \(H_0\) (interaction not significant at 0.05 for this example).

When the interaction is significant, interpretation typically emphasizes simple effects (comparisons within levels) rather than main effects alone.

Visualization: interaction plot of cell means

The interaction plot connects the mean response across B levels for each A level. Non-parallel lines indicate a potential interaction; nearly parallel lines indicate weak interaction.

10 14 18 22 B1 (low) B2 (medium) B3 (high) A2 (new) dashed A1 (none) solid mean height
Solid line: A1 cell means \((10,14,18)\). Dashed line: A2 cell means \((12,19,22)\). Lines are not perfectly parallel, matching the small (not significant at 0.05) interaction in the ANOVA table.
Vote on the accepted answer
Upvotes: 0 Downvotes: 0 Score: 0
Community answers No approved answers yet

No approved community answers are published yet. You can submit one below.

Submit your answer Moderated before publishing

Plain text only. Your name is required. Links, HTML, and scripts are blocked.

Fresh

Most recent questions

109 questions · Sorted by newest first

Showing 1–10 of 109
per page
  1. Mar 5, 2026 Published
    Formula of the Variance (Population and Sample)
    Statistics Numerical Descriptive Measures Measures of Dispersion for Ungrouped Data
  2. Mar 5, 2026 Published
    Mean Median Mode Calculator (Formulas, Interpretation, and Example)
    Statistics Numerical Descriptive Measures Measures of Central Tendency for Ungrouped Data
  3. Mar 4, 2026 Published
    How to Calculate Standard Deviation in Excel (STDEV.S vs STDEV.P)
    Statistics Numerical Descriptive Measures Measures of Dispersion for Ungrouped Data
  4. Mar 4, 2026 Published
    Suppose T and Z Are Random Variables: How T Relates to Z in the t Distribution
    Statistics Estimation of the Mean and Proportion Estimation of a Population Mean σ Not Known the T Distribution
  5. Mar 4, 2026 Published
    What Does R Squared Mean in Statistics (Coefficient of Determination)
    Statistics Simple Linear Regression Coefficient of Determination
  6. Mar 3, 2026 Published
    Box and Plot Graph (Box Plot) Explained
    Statistics Numerical Descriptive Measures Box and Whisker Plot
  7. Mar 3, 2026 Published
    How to Calculate a Z Score
    Statistics Continuous Random Variables and the Normal Distribution Standardizing a Normal Distribution
  8. Mar 3, 2026 Published
    How to Calculate Relative Frequency
    Statistics Organizing and Graphing Data Organizing and Graphing Quantitative Data
  9. Mar 3, 2026 Published
    Is zero an even number?
    Statistics Numerical Descriptive Measures Measures of Central Tendency for Ungrouped Data
  10. Mar 3, 2026 Published
    Monty Hall Paradox (Conditional Probability Explained)
    Statistics Probability Marginal and Conditional Probabilities
Showing 1–10 of 109
Open the calculator for this topic