Factorial Designs

Two-way anova with interactions

Dr. Samuel B Fernandes

2026-01-01

Learning Objectives

By the end of this lectures (we will probably spend two lectures on this), you should be able to:

  • Explain the advantage of factorial designs over one-factor-at-a-time experiments
  • Construct the statistical model for a two-factor factorial: \(y_{ijk} = \mu + \alpha_i + \beta_j + (\alpha\beta)_{ij} + \varepsilon_{ijk}\)
  • Design a factorial experiment using CRD or RCBD structure
  • Create and interpret interaction plots to visualize how factors combine
  • Conduct simple effects analysis when significant interactions are present
  • Make appropriate statistical conclusions when interactions are significant vs non-significant

Packages Used

Code
library(dplyr) # Data wrangling across examples
library(tidyr) # Reshaping data (herbicide example)
library(ggplot2) # Plots throughout
library(gridExtra) # Side-by-side layout comparison
library(FielDHub) # Factorial CRD/RCBD design generation
library(agricolae) # Herbicide RCBD design
library(car) # Type III ANOVA tables
library(emmeans) # Estimated marginal means and comparisons
library(parameters) # Model summaries (herbicide ANOVA)
library(performance) # Model diagnostics
library(multcomp) # Compact letter display

Motivating Question

Research scenario:

You want to study the effects of irrigation and nitrogen fertilizer on corn yield.

Two approaches:

  1. Run two separate experiments (one-factor-at-a-time)
  2. Run one factorial experiment (both factors together)

Which approach is better? 🤔

Review: Single-Factor Designs

CRD (Completely Randomized Design):

  • One factor (treatment) with multiple levels
  • Randomize treatments to experimental units
  • ANOVA: Test treatment effect

Example: Nitrogen (0, 50, 100 kg/ha) on wheat yield

RCBD (Randomized Complete Block Design):

  • One factor + blocking for spatial/temporal variation
  • Complete set of treatments in each block
  • ANOVA: Test treatment effect (accounting for blocks)

Example: Same nitrogen study, blocked by field location

Limitation: Both designs test one factor at a time. What if you want to test irrigation AND nitrogen simultaneously?

Why Factorial Designs?

One-Factor-At-a-Time (OFAT) Approach

Experiment 1: Test Irrigation

  • Low irrigation (L) vs High irrigation (H)
  • Keep nitrogen constant at 50 kg/ha
  • 2 treatments × 8 reps = 16 plots

Result: High irrigation increases yield by 500 kg/ha

Experiment 2: Test Nitrogen

  • No nitrogen (0) vs High nitrogen (100 kg/ha)
  • Keep irrigation constant at Low
  • 2 treatments × 8 reps = 16 plots

Result: Nitrogen increases yield by 300 kg/ha

Problem with OFAT:

  • Total plots: 32
  • Conclusion: “Add high irrigation (+500 kg/ha) and nitrogen (+300 kg/ha) for +800 kg/ha total”
  • Hidden assumption: Effects are independent (additive)
  • Risk: What if nitrogen only works with high irrigation? You’ll never know!

Factorial Solution: Test All Combinations

2×2 Factorial Design:

  • Factor A: Irrigation (Low, High)
  • Factor B: Nitrogen (0, 100 kg/ha)
  • Replication: 8 reps per combination
  • Total plots: 4 × 8 = 32 plots (same as OFAT!)

Treatment combinations: 4 (all possible pairs)

  1. Low Irrigation + No Nitrogen (L0)
  2. Low Irrigation + High Nitrogen (L100)
  3. High Irrigation + No Nitrogen (H0)
  4. High Irrigation + High Nitrogen (H100)

Treatment Structure Table:

Irrigation N = 0 N = 100
Low L0 L100
High H0 H100


Factorial advantage:

  • Same sample size (32 plots)
  • More information: Tests irrigation effect, nitrogen effect, AND their interaction!

Factorial Notation

Factorial designs are described by the number of factors and their levels:

  • 2×2 factorial: 2 factors, each with 2 levels → 4 treatment combinations
  • 3×3 factorial: 2 factors, each with 3 levels → 9 treatment combinations
  • 2×4 factorial: 2 factors (2 levels, 4 levels) → 8 treatment combinations
  • 2×2×2 factorial: 3 factors, each with 2 levels → 8 treatment combinations
  • 2^k factorial: k factors, all with 2 levels → \(2^k\) combinations

Examples:

Design Factors Levels Combinations
2×2 Irrigation (2) × Nitrogen (2) 2, 2 4
3×3 Irrigation (3) × Nitrogen (3) 3, 3 9
2×3 Tillage (2) × Variety (3) 2, 3 6
2×2×2 Tillage × Variety × Fungicide 2, 2, 2 8

Main Effects and Interactions

What is a Main Effect?

Main effect of Factor A:

The average effect of Factor A across all levels of Factor B.

  • Compares marginal means (averaged over other factors)
  • Ignores specific combinations
  • Answers: “On average, does Factor A matter?”

Example: Main effect of Irrigation

Mean yield under Low Irrigation: \[\bar{y}_{\text{Low}} = \frac{y_{L0} + y_{L100}}{2}\]

Average of L0 and L100 (across both nitrogen levels)

Mean yield under High Irrigation: \[\bar{y}_{\text{High}} = \frac{y_{H0} + y_{H100}}{2}\]

Average of H0 and H100

Main effect of Irrigation: \[\text{Main Effect}_{\text{Irrigation}} = \bar{y}_{\text{High}} - \bar{y}_{\text{Low}}\]

What is an Interaction?

Interaction between Factor A and Factor B:

The effect of Factor A depends on the level of Factor B (or vice versa).

  • Main effects are not additive
  • Simple effects (A at each level of B) differ
  • Answers: “Do factors work together in a non-additive way?”

Example: Irrigation × Nitrogen Interaction

If no interaction:

  • Nitrogen effect at Low Irrigation = +200 kg/ha
  • Nitrogen effect at High Irrigation = +200 kg/ha
  • “Nitrogen increases yield by 200 kg/ha regardless of irrigation level”

If interaction present:

  • Nitrogen effect at Low Irrigation = +200 kg/ha
  • Nitrogen effect at High Irrigation = +1000 kg/ha
  • “Nitrogen benefit is much larger under high irrigation!”
  • Factors interact (synergy)

Biological interpretation:

Nitrogen uptake requires adequate water. Under drought (low irrigation), plants can’t utilize added nitrogen. Under high irrigation, nitrogen is fully effective → synergistic interaction.

Interaction Plot

Figure 1: Conceptual interaction plot: Nitrogen effect depends on irrigation

Key observation: Lines are not parallel → Interaction present!

  • Under low irrigation (red): Nitrogen increases yield slightly (3000 → 3200)
  • Under high irrigation (green): Nitrogen increases yield substantially (3500 → 4500)
  • Interpretation: Nitrogen benefit depends on irrigation level

Statistical Model for Factorial Designs

Two-Factor Factorial Model

Mathematical model for 2×2 factorial:

\[y_{ijk} = \mu + \alpha_i + \beta_j + (\alpha\beta)_{ij} + \varepsilon_{ijk}\]

Where:

  • \(y_{ijk}\) = response (e.g., yield) for observation \(k\) in treatment \(i, j\)
  • \(\mu\) = overall mean (grand mean)
  • \(\alpha_i\) = main effect of Factor A (e.g., irrigation), \(i = 1, 2\)
  • \(\beta_j\) = main effect of Factor B (e.g., nitrogen), \(j = 1, 2\)
  • \((\alpha\beta)_{ij}\) = interaction effect between Factors A and B
  • \(\varepsilon_{ijk}\) = random error, \(\varepsilon_{ijk} \sim N(0, \sigma^2)\)

Assumptions

Same assumptions as CRD and RCBD:

  1. Independence: Observations are independent (proper randomization)
  2. Normality: Errors \(\varepsilon_{ijk}\) are normally distributed
  3. Homogeneity of variance: Equal variance across all treatment combinations (\(\sigma^2\) constant)
  4. Additivity: Model is additive (or check for interaction if suspected)

Checking assumptions:

  • Residual plots (normality, constant variance, outliers)
  • Shapiro-Wilk test (normality)
  • Levene’s test (homogeneity of variance)

ANOVA for Factorial Design

ANOVA partitions total variation into:

\[\text{SS}_{\text{Total}} = \text{SS}_A + \text{SS}_B + \text{SS}_{A \times B} + \text{SS}_{\text{Error}}\]

Sources of variation:

  1. Main effect of Factor A (irrigation)
  2. Main effect of Factor B (nitrogen)
  3. Interaction A×B (irrigation × nitrogen)
  4. Error (within-treatment variation)

ANOVA Table Structure:

Source df SS MS F p-value
Factor A \(a-1\) \(SS_A\) \(MS_A\) \(\frac{MS_A}{MS_E}\)
Factor B \(b-1\) \(SS_B\) \(MS_B\) \(\frac{MS_B}{MS_E}\)
A×B \((a-1)(b-1)\) \(SS_{A \times B}\) \(MS_{A \times B}\) \(\frac{MS_{A \times B}}{MS_E}\)
Error \(ab(r-1)\) \(SS_E\) \(MS_E\)
Total \(abr - 1\) \(SS_{\text{Total}}\)

Hypotheses Tested

Main effect of Factor A (Irrigation):

\[H_0: \alpha_1 = \alpha_2 = 0\] \[H_A: \text{At least one } \alpha_i \neq 0\]

“Is there an average difference between irrigation levels?”

Main effect of Factor B (Nitrogen):

\[H_0: \beta_1 = \beta_2 = 0\] \[H_A: \text{At least one } \beta_j \neq 0\]

“Is there an average difference between nitrogen levels?”

Interaction A×B (Irrigation × Nitrogen):

\[H_0: (\alpha\beta)_{ij} = 0 \text{ for all } i, j\] \[H_A: \text{At least one } (\alpha\beta)_{ij} \neq 0\]

“Does the effect of nitrogen depend on irrigation level (or vice versa)?”

Designing a Factorial Experiment

Factorial + CRD Structure

Factorial CRD:

  • Treatment structure: Factorial (e.g., 2×2 = 4 combinations)
  • Design structure: Completely randomized (no blocks)
  • Randomize all treatment combinations to experimental units

When to use:

  • Homogeneous experimental environment
  • No obvious blocking factor

Example R code with FielDHub:

Code
# Generate 2×2 factorial CRD
design_factorial_crd <- FielDHub::CRD(
    t = 4, # 4 treatment combinations (2×2)
    reps = 8, # 8 replicates
    plotNumber = 101,
    seed = 2026,
    locationName = "Research Farm"
)

# View layout
print(design_factorial_crd)
plot(design_factorial_crd)

Factorial + RCBD Structure

Factorial RCBD:

  • Treatment structure: Factorial (e.g., 2×2 = 4 combinations)
  • Design structure: Randomized complete block
  • Each block contains all 4 treatment combinations (complete)

When to use:

  • Heterogeneous environment (field gradient, time variability)
  • Want to control for blocking factor

Example R code with FielDHub:

Code
# Generate 2×2 factorial RCBD
design_factorial_rcbd <- FielDHub::RCBD(
    t = 4, # 4 treatment combinations (2×2)
    reps = 8, # 8 blocks
    plotNumber = 101,
    seed = 2026,
    locationName = "Field Trial"
)

# View layout
print(design_factorial_rcbd)
plot(design_factorial_rcbd)

Design Considerations

Key design decisions for factorials:

  1. How many factors?

    • Start with 2-3 factors (more factors = exponential growth in plots)
    • Example: 2×2×2 = 8 combinations; 3×3×3 = 27 combinations
  2. How many levels per factor?

    • 2 levels: Compare two conditions (yes/no, low/high)
    • 3+ levels: Dose-response, multiple varieties
  3. Replication:

    • Need sufficient power: 6-10 reps per combination typical
    • Power analysis: Estimate from pilot data or literature
  4. Design structure:

    • CRD if environment homogeneous
    • RCBD if spatial/temporal variation expected

What is an Interaction?

Interaction: Definition

Interaction between Factor A and Factor B:

The effect of Factor A depends on the level of Factor B (or equivalently, the effect of Factor B depends on the level of Factor A).

Synonyms:

  • Non-additive effect
  • Synergistic/antagonistic effect
  • Conditional effect
  • Moderation

Key insight: When an interaction is present, you cannot interpret main effects in isolation—you must consider factor combinations.

No Interaction vs Interaction

Scenario 1: No Interaction (Additive)

Irrigation N=0 N=100 N effect
Low 3000 3400 +400
High 3500 3900 +400
Irrig effect +500 +500

✓ Nitrogen effect is the same (+400) at both irrigation levels

✓ Irrigation effect is the same (+500) at both nitrogen levels

✓ Effects are additive

Scenario 2: Interaction Present

Irrigation N=0 N=100 N effect
Low 3000 3200 +200
High 3500 4500 +1000
Irrig effect +500 +1300

Caution

✗ Nitrogen effect differs (+200 vs +1000)

✗ Irrigation effect differs (+500 vs +1300)

✗ Effects are non-additiveInteraction!

Visual Check: Interaction Plots

Interaction plot:

  • X-axis: One factor (e.g., Nitrogen)
  • Y-axis: Response (e.g., Yield)
  • Lines: Levels of the other factor (e.g., Irrigation)

Interpretation rule:

  • Parallel lines → No interaction (additive effects)
  • Non-parallel lines → Interaction present (non-additive effects)

Interaction Plot: No Interaction

Code
library(ggplot2)
library(dplyr)

# Data: No interaction (additive)
no_interaction <- data.frame(
  Irrigation = rep(c("Low", "High"), each = 2),
  Nitrogen = rep(c("0", "100"), times = 2),
  Yield = c(3000, 3400, 3500, 3900)  # N adds 400 everywhere
)

no_interaction$Irrigation <- factor(no_interaction$Irrigation, levels = c("Low", "High"))
no_interaction$Nitrogen <- factor(no_interaction$Nitrogen, levels = c("0", "100"))

# Interaction plot
ggplot(no_interaction, aes(x = Nitrogen, y = Yield, 
                           color = Irrigation, group = Irrigation)) +
  geom_line(linewidth = 2) +
  geom_point(size = 6) +
  labs(
    title = "No Interaction: Parallel Lines",
    subtitle = "Nitrogen effect is the same (+400 kg/ha) under both irrigation levels",
    x = "Nitrogen Level (kg/ha)",
    y = "Corn Yield (kg/ha)",
    color = "Irrigation"
  ) +
  scale_color_manual(values = c("Low" = "#9D2235", "High" = "#2E8B57")) +
  scale_y_continuous(limits = c(2500, 4500), breaks = seq(2500, 4500, 500)) +
  theme_minimal(base_size = 18) +
  theme(
    plot.title = element_text(color = "#2E8B57", face = "bold", size = 20),
    plot.subtitle = element_text(size = 16),
    legend.position = "right",
    legend.title = element_text(size = 16),
    legend.text = element_text(size = 14)
  )

Figure 2: No interaction: Parallel lines indicate additive effects

Parallel lines: Slope is identical for both irrigation levels → No interaction. You can interpret main effects directly.

Interaction Plot: Synergistic Interaction

Code
# Data: Synergistic interaction
synergistic <- data.frame(
  Irrigation = rep(c("Low", "High"), each = 2),
  Nitrogen = rep(c("0", "100"), times = 2),
  Yield = c(3000, 3200, 3500, 4500)  # N effect larger under high irrigation
)

synergistic$Irrigation <- factor(synergistic$Irrigation, levels = c("Low", "High"))
synergistic$Nitrogen <- factor(synergistic$Nitrogen, levels = c("0", "100"))

# Interaction plot
ggplot(synergistic, aes(x = Nitrogen, y = Yield, 
                        color = Irrigation, group = Irrigation)) +
  geom_line(linewidth = 2) +
  geom_point(size = 6) +
  labs(
    title = "Synergistic Interaction: Nitrogen Works Better with High Irrigation",
    subtitle = "Non-parallel lines diverge: Nitrogen effect depends on irrigation level",
    x = "Nitrogen Level (kg/ha)",
    y = "Corn Yield (kg/ha)",
    color = "Irrigation"
  ) +
  scale_color_manual(values = c("Low" = "#9D2235", "High" = "#2E8B57")) +
  scale_y_continuous(limits = c(2500, 5000), breaks = seq(2500, 5000, 500)) +
  theme_minimal(base_size = 18) +
  theme(
    plot.title = element_text(color = "#2E8B57", face = "bold", size = 20),
    plot.subtitle = element_text(size = 16),
    legend.position = "right",
    legend.title = element_text(size = 16),
    legend.text = element_text(size = 14)
  )

Figure 3: Synergistic interaction: Nitrogen effect amplified under high irrigation

Non-parallel lines (diverging): Green line (high irrigation) has steeper slope than red line (low irrigation) → Synergistic interaction. Factors amplify each other’s effects.

Types of Interactions

Synergistic Interaction

Synergistic interaction:

The combined effect of two factors is greater than the sum of their individual effects.

Visual cue: Non-parallel lines that diverge (spread apart)

Example: Fungicide + resistant variety control disease better together than expected from their individual effects

Why it happens:

  • Factors amplify each other’s effects
  • Common in biology: Nutrients need water, herbicides need adjuvants, genes interact epistatically

Practical implication:

  • “Use both factors together for maximum benefit”
  • Combined treatment is most cost-effective

Antagonistic Interaction

Antagonistic interaction:

The combined effect of two factors is less than the sum of their individual effects.

Visual cue: Non-parallel lines that converge (come together)

Example: High temperature reduces fertilizer benefit (heat stress limits nutrient uptake)

Why it happens:

  • One factor dampens or limits the effect of the other
  • Stress conditions, resource competition, physiological constraints

Practical implication:

  • “One factor might not be worth adding if the other is unfavorable”
  • Optimize one factor before investing in the other

Crossover Interaction

Crossover interaction:

The ranking of one factor’s levels reverses depending on the level of the other factor.

Visual cue: Lines cross each other

Example: Variety A best in Location 1, but Variety B best in Location 2 (genotype × environment interaction)

Figure 4: Crossover interaction: Rankings reverse across locations

Summary: Types of Interactions

Type Visual Cue Effect Example
Synergistic Lines diverge Combined effect > sum Fertilizer + irrigation amplify each other
Antagonistic Lines converge Combined effect < sum Heat stress reduces fertilizer benefit
Crossover Lines cross Rankings reverse Variety A best in Loc 1; Variety B best in Loc 2
No interaction Lines parallel Effects additive Nitrogen adds same amount everywhere

Key message: The type of interaction dictates your management recommendations. Always visualize interactions with plots!

ANOVA for Factorial Designs

ANOVA Table for 2×2 Factorial

Factorial ANOVA tests THREE hypotheses:

  1. Main effect of Factor A (e.g., Irrigation)
  2. Main effect of Factor B (e.g., Nitrogen)
  3. Interaction A×B (Irrigation × Nitrogen)

Critical rule: Test the interaction first! Interpretation depends on whether interaction is significant.

ANOVA table structure:

Source df SS MS F p-value
Irrigation (A) \(a-1 = 1\) \(SS_A\) \(MS_A\) \(F_A\) \(p_A\)
Nitrogen (B) \(b-1 = 1\) \(SS_B\) \(MS_B\) \(F_B\) \(p_B\)
A×B Interaction \((a-1)(b-1) = 1\) \(SS_{AB}\) \(MS_{AB}\) \(F_{AB}\) \(p_{AB}\)
Error \(ab(r-1) = 28\) \(SS_E\) \(MS_E\)
Total \(abr-1 = 31\) \(SS_{\text{Total}}\)

Interpretation Decision Tree

Step 1: Test interaction

  • If p(A×B) < 0.05Interaction is significant
    • Action: Conduct simple effects analysis (test Factor A at each level of Factor B separately)
    • Do NOT interpret main effects alone—they’re misleading!
  • If p(A×B) ≥ 0.05Interaction is not significant
    • Action: Interpret main effects (Factor A and Factor B)
    • Factors work independently (additive)

Common mistake:

“My interaction is significant (p < 0.05), but I’ll still report main effects.”

Wrong! If interaction is significant, main effects don’t tell the full story. You must analyze simple effects.

Simple Effects Analysis

What Are Simple Effects?

Simple effect:

The effect of one factor at a specific level of another factor.

When to use: When the interaction is significant (p < 0.05)

Example: - Simple effect of Nitrogen at Low Irrigation - Simple effect of Nitrogen at High Irrigation

Answers: “Does nitrogen matter under low irrigation? Does nitrogen matter under high irrigation?”

R Code: Simple Effects with emmeans

Code
library(emmeans)
library(car)

# Assume you've fitted a model:
# model <- lm(Yield ~ Irrigation * Nitrogen, data = factorial_data)

# Step 1: Test interaction
Anova(model, type = "III")

# If interaction p < 0.05, proceed to simple effects:

# Step 2: Simple effects of Nitrogen at each Irrigation level
emm_simple <- emmeans(model, ~ Nitrogen | Irrigation)
summary(emm_simple)

# Step 3: Pairwise comparisons within each Irrigation level
pairs(emm_simple)

# Step 4: Visualize with interaction plot
emmip(model, Irrigation ~ Nitrogen, CIs = TRUE)

emmeans syntax:

  • ~ Nitrogen | Irrigation means “Test Nitrogen effect at each level of Irrigation
  • pairs() conducts pairwise comparisons (e.g., N=0 vs N=100) within each irrigation level
  • emmip() creates an interaction plot with confidence intervals

Example: Simple Effects Output

Hypothetical emmeans output:

Irrigation = Low:
 Nitrogen emmean    SE  df lower.CL upper.CL
 0          3000  50  28     2900     3100
 100        3200  50  28     3100     3300

Irrigation = High:
 Nitrogen emmean    SE  df lower.CL upper.CL
 0          3500  50  28     3400     3600
 100        4500  50  28     4400     4600

Pairwise comparisons:

Irrigation = Low:
 contrast   estimate   SE df t.ratio p.value
 0 - 100       -200   71 28  -2.82   0.009

Irrigation = High:
 contrast   estimate   SE df t.ratio p.value
 0 - 100      -1000   71 28 -14.08   <.0001

Interpretation:

  • Low irrigation: Nitrogen increases yield by 200 kg/ha (p = 0.009, significant but modest)
  • High irrigation: Nitrogen increases yield by 1000 kg/ha (p < 0.0001, highly significant)
  • Conclusion: Nitrogen benefit is 5× larger under high irrigation → Strong interaction!

R Demo: Complete Factorial Analysis

Example Dataset: Irrigation × Nitrogen

Code
library(dplyr)
library(ggplot2)
library(car)
library(emmeans)

# Simulate factorial data with interaction
set.seed(2026)
factorial_data <- expand.grid(
  Irrigation = factor(c("Low", "High"), levels = c("Low", "High")),
  Nitrogen = factor(c("0", "100"), levels = c("0", "100")),
  Rep = 1:8
) |>
  mutate(
    # True means with interaction
    mu = case_when(
      Irrigation == "Low" & Nitrogen == "0" ~ 3000,
      Irrigation == "Low" & Nitrogen == "100" ~ 3200,
      Irrigation == "High" & Nitrogen == "0" ~ 3500,
      Irrigation == "High" & Nitrogen == "100" ~ 4500
    ),
    Yield = mu + rnorm(n(), mean = 0, sd = 150)  # Add random error
  )

# Preview data
head(factorial_data, 10)
#>    Irrigation Nitrogen Rep   mu    Yield
#> 1         Low        0   1 3000 3078.088
#> 2        High        0   1 3500 3338.046
#> 3         Low      100   1 3200 3220.886
#> 4        High      100   1 4500 4487.288
#> 5         Low        0   2 3000 2900.004
#> 6        High        0   2 3500 3122.587
#> 7         Low      100   2 3200 3089.728
#> 8        High      100   2 4500 4346.982
#> 9         Low        0   3 3000 3017.033
#> 10       High        0   3 3500 3428.931

Step 1: Interaction Plot

Code
# Compute summary statistics
factorial_summary <- factorial_data |>
  group_by(Irrigation, Nitrogen) |>
  summarise(
    mean_yield = mean(Yield),
    se_yield = sd(Yield) / sqrt(n()),
    .groups = "drop"
  )

# Interaction plot
ggplot(factorial_summary, aes(x = Nitrogen, y = mean_yield, 
                              color = Irrigation, group = Irrigation)) +
  geom_line(linewidth = 2) +
  geom_point(size = 6) +
  geom_errorbar(aes(ymin = mean_yield - se_yield, ymax = mean_yield + se_yield),
                width = 0.1, linewidth = 1) +
  labs(
    title = "Interaction Plot: Nitrogen Effect Depends on Irrigation",
    subtitle = "Non-parallel lines suggest an interaction",
    x = "Nitrogen Level (kg/ha)",
    y = "Mean Corn Yield (kg/ha)",
    color = "Irrigation"
  ) +
  scale_color_manual(values = c("Low" = "#9D2235", "High" = "#2E8B57")) +
  scale_y_continuous(limits = c(2500, 5000), breaks = seq(2500, 5000, 500)) +
  theme_minimal(base_size = 18) +
  theme(
    plot.title = element_text(color = "#2E8B57", face = "bold", size = 20),
    plot.subtitle = element_text(size = 16),
    legend.position = "right"
  )

Figure 5: Interaction plot: Nitrogen × Irrigation on corn yield

Lines are non-parallel (diverging) → Suggests interaction. Let’s test it statistically!

Step 2: Fit Model and ANOVA

Code
# Fit factorial model with interaction
model_factorial <- lm(Yield ~ Irrigation * Nitrogen, data = factorial_data)

# Type III ANOVA (tests main effects and interaction)
Anova(model_factorial, type = "III")
#> Anova Table (Type III tests)
#> 
#> Response: Yield
#>                       Sum Sq Df   F value    Pr(>F)    
#> (Intercept)         72656092  1 2813.9233 < 2.2e-16 ***
#> Irrigation            902301  1   34.9455 2.323e-06 ***
#> Nitrogen               40908  1    1.5844    0.2185    
#> Irrigation:Nitrogen  1788913  1   69.2834 4.679e-09 ***
#> Residuals             722966 28                        
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

ANOVA results:

  • Irrigation: Significant (p < 0.001) → High irrigation increases yield on average
  • Nitrogen: Significant (p < 0.001) → Nitrogen increases yield on average
  • Irrigation × Nitrogen: Significant (p < 0.001) → Interaction present!

Interpretation: Since interaction is significant, we must conduct simple effects analysis. Main effects alone are insufficient.

Step 3: Simple Effects Analysis

Code
# Estimated marginal means: Nitrogen at each Irrigation level
emm_simple <- emmeans(model_factorial, ~ Nitrogen | Irrigation)
summary(emm_simple)
#> Irrigation = Low:
#>  Nitrogen emmean   SE df lower.CL upper.CL
#>  0          3014 56.8 28     2897     3130
#>  100        3115 56.8 28     2998     3231
#> 
#> Irrigation = High:
#>  Nitrogen emmean   SE df lower.CL upper.CL
#>  0          3489 56.8 28     3372     3605
#>  100        4535 56.8 28     4419     4652
#> 
#> Confidence level used: 0.95
Code
# Pairwise comparisons (simple effects)
pairs(emm_simple)
#> Irrigation = Low:
#>  contrast                estimate   SE df t.ratio p.value
#>  Nitrogen0 - Nitrogen100     -101 80.3 28  -1.259  0.2185
#> 
#> Irrigation = High:
#>  contrast                estimate   SE df t.ratio p.value
#>  Nitrogen0 - Nitrogen100    -1047 80.3 28 -13.030  <.0001

Simple effects results:

  • Low Irrigation: Nitrogen increases yield by ~200 kg/ha (p < 0.01, significant but modest)
  • High Irrigation: Nitrogen increases yield by ~1000 kg/ha (p < 0.0001, highly significant)

Practical conclusion:

  • Nitrogen is beneficial under both irrigation levels, but the benefit is 5× larger under high irrigation
  • Recommendation depends on context: If irrigation is limited, nitrogen ROI is lower

Step 4: Visualize Simple Effects

Code
# Interaction plot with emmeans (includes CIs)
emmip(model_factorial, Irrigation ~ Nitrogen, CIs = TRUE, 
      linewidth = 1.5, dotsize = 4) +
  labs(
    title = "Estimated Marginal Means: Nitrogen × Irrigation",
    subtitle = "Confidence intervals show precision of estimates",
    x = "Nitrogen Level (kg/ha)",
    y = "Estimated Mean Yield (kg/ha)",
    color = "Irrigation"
  ) +
  scale_color_manual(values = c("Low" = "#9D2235", "High" = "#2E8B57")) +
  theme_minimal(base_size = 18) +
  theme(
    plot.title = element_text(color = "#2E8B57", face = "bold", size = 20),
    plot.subtitle = element_text(size = 16),
    legend.position = "right"
  )

Figure 6: Simple effects: Nitrogen effect at each irrigation level

Your Turn: Interpret an Interaction

Activity (3 minutes)

Scenario:

You tested two tillage methods (Conventional, No-till) and two fungicide treatments (None, Applied) on soybean yield. Here are the means:

Tillage Fungicide=None Fungicide=Applied Fungicide effect
Conventional 2800 kg/ha 2850 kg/ha +50 kg/ha
No-till 2500 kg/ha 3200 kg/ha +700 kg/ha

Questions: 1. Is there an interaction? How do you know? 2. What type of interaction (synergistic, antagonistic, crossover)? 3. What would you recommend to a farmer using no-till? Conventional tillage?

Discuss with a partner, then we’ll share answers.

Activity: Solutions

Answers:

  1. Yes, interaction present
    • Fungicide effect is +50 kg/ha under conventional tillage
    • Fungicide effect is +700 kg/ha under no-till
    • Effects differ → Interaction!
  2. Synergistic interaction
    • Fungicide benefit is amplified under no-till
    • Lines would diverge on an interaction plot
  1. Recommendations:

For no-till farmers: - Definitely apply fungicide (+700 kg/ha gain!) - Strong ROI due to higher disease pressure

For conventional tillage farmers: - Fungicide helps only slightly (+50 kg/ha) - May not justify cost (marginal benefit)

Key lesson: Management advice depends on tillage system due to interaction!

Key Takeaways

  1. Factorial designs test multiple factors simultaneously in one experiment
  2. OFAT (one-factor-at-a-time) is inefficient and misses interactions
  3. Main effects = average effect of a factor across all levels of other factors
  4. Interactions = effect of one factor depends on the level of another factor
  5. Model: \(y_{ijk} = \mu + \alpha_i + \beta_j + (\alpha\beta)_{ij} + \varepsilon_{ijk}\)
  6. ANOVA tests main effects (A, B) and interaction (A×B) separately
  7. Design structure: Use CRD or RCBD depending on experimental environment
  8. Efficiency advantage: More information per experimental unit

Factorial Advantages

Why use factorial designs?

Efficiency: Test multiple factors in one experiment (saves time, resources)

Interaction detection: OFAT misses interactions; factorial reveals them

Broader inference: Results apply across levels of other factors

Practical relevance: Real-world questions are multifactorial

Statistical power: Each data point contributes to multiple effects

Resources

Required reading: - Oehlert (2010), A First Course in Design and Analysis of Experiments, Chapter 8

R packages:

  • FielDHub (experimental design generation)
  • car (Type III ANOVA)
  • emmeans (estimated marginal means)
  • ggplot2 (visualization)

Key functions:

  • emmeans(model, ~ FactorB | FactorA) → Simple effects
  • pairs(emm_object) → Pairwise comparisons
  • emmip(model, FactorA ~ FactorB, CIs = TRUE) → Interaction plot with CIs

Additional resources:

  • Montgomery (2017), Design and Analysis of Experiments, Chapter 5
  • Agronomic examples: agridat package datasets