Do the Effects Combine
df has columns soil and light (names of conditions) and growth. Does the effect of the light depend on the soil? Fit growth on both conditions and their interaction, treating both as categories, and return the p-value of the interaction from a type 2 analysis of variance table.
Example 1
df {"soil":["a","a","a","a","b","b","b","b"],"light":["lo","lo","hi","hi","lo","lo","hi","hi"],"growth":[5,6,9,10,7,8,11,12]}
returns 1.0
More light adds 4 in both soils: the two effects simply add up.
Example 2
df {"soil":["a","a","a","a","b","b","b","b"],"light":["lo","lo","hi","hi","lo","lo","hi","hi"],"growth":[5,6,9,10,9,10,5,6]}
returns 0.001323896909217167
More light helps in soil a and hurts in soil b: the effect of light depends entirely on the soil.
Constraints
- 2 or 3 soils, 2 lights, at least 2 rows for every combination
len(df) <= 60
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.