Contents/ Part XXVII · Capstone Projects: Statistical Testing/ Chapter 166

Does the Fertilizer Work? It Depends.

Capstone 7. Two factors at once, fertilizer and light, on plant growth. A factorial design asks a question neither factor can answer alone: does the effect of one depend on the level of the other? When the answer is yes, the main effects stop meaning what they appear to mean.

⏱️ ~18 min read
🧪 Two-way ANOVA
📊 Chapter 166

Every capstone so far studied one factor at a time. But the world rarely varies one thing at a time, and when two factors act together the interesting question is usually not "does A matter" or "does B matter" but does A matter more when B is high? That question has a name, the interaction, and only a factorial design can answer it.

The brief
Setting
A greenhouse trial crossed two fertilizers (Standard, Premium) with three light levels (Low, Medium, High), growing twelve plants in each of the six combinations and measuring growth in centimeters.
The question
Does fertilizer matter, does light matter, and does the effect of fertilizer depend on the light level?
Why it matters
The grower has to issue one purchasing recommendation. If Premium only pays off under bright light, a blanket recommendation wastes money in every low-light house.
What we do
Run a two-way ANOVA, read the interaction before either main effect, check the model's assumptions, and turn the result into three separate decisions instead of one verdict.
Two-way ANOVA tests two crossed factors at once. It reports two main effects (the average effect of each factor) and their interaction (whether the effect of one changes across levels of the other). When the interaction is significant, the main effects must not be read alone; the honest description is the set of simple effects.
🌱
The finding, up front

Both factors are significant, but the headline is the interaction (F(2, 62) = 9.74, p = 0.0002). Premium fertilizer is not better at low light (−1.05 cm, p = 0.53), only marginally better at medium light (+2.31 cm, p = 0.08), and clearly better at high light (+7.68 cm, p < 0.001). "Premium fertilizer increases growth" is true on average and misleading in practice.

1

Three Questions in One Design

A greenhouse trial crossed two fertilizers (Standard, Premium) with three light levels (Low, Medium, High), growing twelve plants in each of the six combinations and measuring growth in centimetres. Crossing the factors lets one experiment answer three questions instead of two.

Null hypothesisWhat it claims
Fertilizer (main effect)The two fertilizers give the same mean growth, averaging over light.
Light (main effect)The three light levels give the same mean growth, averaging over fertilizer.
InteractionThe effect of fertilizer is the same at every light level.

That third hypothesis is what a factorial design buys. Running two separate one-way ANOVAs would answer the first two questions and never ask the third, which in this dataset turns out to be the only one that matters for a recommendation.

2

Clean It, Then Read the Cells

Both factor labels arrived inconsistently cased, so they were standardized first; then duplicate rows, missing values, and impossible growth measurements (a −3 cm and a 250 cm) were removed, taking 74 rows to 68. With a factorial design the thing to read is not the margins but the six cell means.

LightStandardPremiumPremium advantage
Low18.41 (n=9)17.36 (n=12)−1.05 cm
Medium24.99 (n=12)27.30 (n=12)+2.31 cm
High27.65 (n=12)35.33 (n=11)+7.68 cm

Read down the last column. The Premium advantage is not a constant: it is slightly negative at low light, small at medium, and large at high. The gap grows with light, and a gap that changes is precisely what an interaction is.

3

What an Interaction Looks Like

The essential picture for a factorial design is the interaction plot: one line per level of one factor, drawn across the levels of the other. The shape of those lines tells you the answer before any test does.

Read the shape of the lines NO INTERACTION same gap everywhere INTERACTION (THIS STUDY) the gap grows CROSSOVER INTERACTION which is better reverses Parallel lines mean one factor's effect is the same everywhere. Anything else means it is not.
Two panels. On the left, every individual plant's growth plotted by light level and fertilizer; at Low light the two fertilizers overlap, at High light the Premium points sit clearly above the Standard ones. On the right, the interaction plot: two lines of mean growth across Low, Medium and High light, which start together near 18 cm and fan apart so that at High light Premium reaches about 35 cm against Standard's 28 cm.
Left: every plant. Right: the interaction plot. The two lines start together at Low light and fan apart as light increases. Parallel lines would mean a constant fertilizer benefit; these are not parallel.
4

Check the Model's Assumptions

A factorial ANOVA asks for the familiar two conditions, applied to the fitted model: residuals roughly normal, and similar variance across all six cells. We fit the model first, then examine what it leaves behind.

Two diagnostic panels. On the left, a normal quantile-quantile plot of the model residuals whose points follow the diagonal reference line, with a Shapiro-Wilk p-value of 0.12. On the right, residuals plotted against fitted values, scattered evenly around a dashed zero line with no funnel shape and no curvature.
The residuals track the Q-Q line (Shapiro-Wilk p = 0.12), and the residuals-versus-fitted plot shows no funnel (variance is not growing with the mean) and no curve (no missing term). The model is sound.
AssumptionCheckResult
Normality of residualsShapiro-WilkW = 0.972, p = 0.12
Equal varianceLevene across all 6 cellsW = 0.341, p = 0.89
Independencedesign: one plant per cell, no repeatssatisfied
5

Read the Interaction First

This is the rule that makes factorial analysis different: look at the interaction before the main effects. If it is significant, "the effect of fertilizer" is not a single number, and the main effect that claims to be one becomes a weighted average of several different effects.

TermFdfpPartial η²
Light (main effect)96.502, 62< 0.0010.757
Fertilizer (main effect)14.961, 620.00030.194
Fertilizer × Light9.742, 620.00020.239
How to read a two-way ANOVA Test the interaction FIRST here: F(2,62) = 9.74, p = 0.0002 not significant Interpret the main effects each factor has one average effect significant Report SIMPLE effects instead fertilizer effect within each light level our path this project

The interaction is significant, so we report simple effects: the fertilizer contrast computed separately within each light level. This is the only honest way to describe what the fertilizer does.

Light levelPremium − Standard95% CIpCohen's dVerdict
Low−1.05 cm[−4.52, +2.41]0.53−0.28no benefit
Medium+2.31 cm[−0.30, +4.92]0.08+0.75not significant
High+7.68 cm[+4.89, +10.47]< 0.001+2.41large benefit
The Premium minus Standard growth difference at each light level, each with a 95% confidence interval. At Low light the point sits slightly below zero with an interval spanning zero, marked not significant. At Medium light the point is above zero but its interval still touches zero, marked not significant. At High light the point sits at about plus 7.7 centimetres with an interval well clear of zero, marked significant.
The fertilizer effect is three different numbers, and only one of them is real. Its interval clears zero only at high light.
Why the main effect misleads here

The fertilizer main effect is significant (p = 0.0003), and quoted on its own it would tell a grower that Premium fertilizer works. It is a genuine average, but it averages −1.05, +2.31, and +7.68. No plant in this trial experienced that average. Under a significant interaction, the average effect is a statistic without a referent.

6

The Verdict and Its Limits

Light dominates growth under either fertilizer, explaining about three quarters of the variation. Fertilizer is conditional: Premium is worth paying for only when light is plentiful. At low light it does nothing measurable, and at medium light its advantage cannot be distinguished from zero at this sample size. The recommendation is therefore not "use Premium" but "use Premium in high-light conditions", which is a different and more useful sentence.

7

Interactions in Data Science & AI

The idea that an effect depends on context is one of the most transferable in all of statistics, and it reappears under many names.

Where it appearsThe interaction
Heterogeneous treatment effectsAn experiment helps one segment and not another; the average treatment effect hides both.
Full-factorial experimentsTwo product changes tested together, to catch the case where each helps alone but not combined.
Interaction terms in regressionThe same idea in model form: a coefficient on the product of two predictors.
Fairness auditingA model that performs well overall but poorly for one subgroup is an interaction between the model and group membership.
Practice note

The single most common misreading of experimental results in industry is quoting an average effect when the effect is conditional. Averages are the right summary only when the effect is roughly constant; when it is not, the average describes no one. The habit this capstone teaches, test the interaction before you trust the average, carries directly into segment analysis and heterogeneous-treatment-effect work, where the modern tools differ but the logic does not.

8

Estimate: Three Decisions, Not One Verdict

The interaction told us the fertilizer effect depends on light, and the simple effects gave the direction at each level. Intervals give the size, and they turn a statistical finding into something a grower can act on.

Light levelPremium minus Standard95% confidence intervalBuying advice
Low−1.05 cm−4.52 to +2.41do not pay for it
Medium+2.31 cm−0.30 to +4.92unresolved
High+7.68 cm+4.89 to +10.47premium pays

Under high light, premium fertilizer adds between about 4.9 and 10.5 cm, so it pays and the only question is how much. Under low light the interval is compatible with premium being slightly worse. Buy premium for the bright benches; do not buy it for the dim ones. No single averaged number could carry that message, which is exactly why reading the main effect first would have been the wrong move.

9

The One Capstone Where "Caused" Is the Right Word

Almost every chapter in this part ends by warning against causal language. This one does not, and the reason is worth being explicit about, because the difference lies in the design rather than in the statistics.

OBSERVED (capstones 3, 8, 11, 12, 15, 16) ASSIGNED (this capstone) treatment outcome third variable both red arrows are open: the link may be spurious treatment outcome third variable assignment CUTS the arrow into treatment
Randomization is scissors. In an observational study a third variable can feed both the exposure and the outcome, and the correlation between them may be entirely its doing. When the experimenter assigns the treatment, nothing about the plant can influence which condition it receives, so that arrow is severed and the remaining path is causal.

In Capstone 11 we measured study hours as students happened to report them, so a correlation could reflect hours causing scores, ease causing hours, or prior ability causing both. Here the experimenter set the light level and the fertilizer. Plants did not choose the bright bench, and a plant's own vigor cannot have influenced which treatment it received.

That single design feature closes off the alternatives. Reverse causation is impossible, since growth cannot reach back and change the fertilizer applied last month. Confounding is handled by allocation, since any pre-existing difference between plants is scattered across the six cells rather than lining up with treatment. Everything else was held constant by the greenhouse.

The transferable lesson

So this chapter may say caused, and it should. The point is not that experiments are better analyses. The statistics here are no more sophisticated than in the observational capstones and in places they are simpler. The point is that causal claims are earned in the design, before any data are collected, and no amount of careful analysis afterwards can substitute for them.

🐍

The full project, step by step

The companion notebook runs all twelve framework steps: it standardizes both factor labels and cleans the file with a printed audit trail, tabulates the six cell means, draws the interaction plot, fits the factorial model with statsmodels, checks residual normality and equal variance across cells, reads the ANOVA table interaction-first with partial eta-squared for every term, and computes the simple effects within each light level. Every number here comes from its output, with a plain-language note after each result.

📓 View Notebook (code & outputs) ▶ Open in Colab ⬇ View / Download on GitHub
Read the reports & get the data

The dataset (capstone-plant-growth-two-factors.xlsx) holds the trial on the plants sheet, with a codebook and notes, and it keeps the inconsistent labels, blanks, duplicates, and impossible values so you can practice the cleaning. Two written reports accompany it: a plain-language brief for a grower, and a technical report with the full factorial ANOVA table, simple-effects analysis, diagnostics, and references.

🎓 Key Takeaways

  • A factorial design asks a third question: not just whether each factor matters, but whether the effect of one depends on the other.
  • Read the interaction first. Here it was significant (F(2, 62) = 9.74, p = 0.0002, partial η² = 0.24), which changes how the main effects may be used.
  • Parallel lines mean no interaction; lines that fan or cross mean the effect is conditional. This interaction plot fans.
  • Report simple effects: Premium fertilizer gave −1.05 cm at low light (p = 0.53), +2.31 at medium (p = 0.08), and +7.68 at high (p < 0.001).
  • A significant main effect can describe no one: the fertilizer average pooled −1.05, +2.31, and +7.68, a value no plant in the trial experienced.
10

Quiz: Test Yourself

Eight questions on this capstone, from interaction plots to simple effects. Answer them, hit Check Answers, and keep refining until you score 100%. Your progress is saved.