Why Compare Two Differences?
A genotype and an environmental exposure may each be associated with a quantitative trait. The effect of exposure need not be the same in every genotype group. To describe how those exposure differences vary, compare the mean outcome difference between exposure levels in one genotype group with the corresponding difference in another. This comparison of two differences is called a difference-in-differences.
For a quantitative trait, the contrast is on the outcome’s original additive scale: its units are the same as the trait’s units. For example, if the trait is blood pressure measured in mmHg, an additive interaction contrast is also measured in mmHg. The word “additive” identifies the scale of the comparison; it does not, on its own, establish that genotype or exposure causes the outcome.
The four means have a direct interpretation: \(\mu_{00}\) is the mean for genotype group 0 at exposure level 0; \(\mu_{01}\) is for group 0 at exposure level 1; \(\mu_{10}\) is for group 1 at exposure level 0; and \(\mu_{11}\) is for group 1 at exposure level 1. The contrast can be calculated in either of two equivalent ways:
The first form subtracts the exposure difference in genotype group 0 from the exposure difference in group 1. The second subtracts the genotype difference at exposure level 0 from the genotype difference at exposure level 1. Both describe the same departure from additivity of the four means.
Deriving the Linear-Model Coefficient
With both variables coded \(0\) or \(1\), a linear model containing their main effects and product term is
Here \(\beta_0\) is the fitted mean for \(G=0,E=0\); \(\beta_G\) and \(\beta_E\) are main-effect coefficients under this coding; and \(\beta_{GE}\) is the product-term coefficient. The fitted means at the four combinations are obtained by substituting the relevant values of \(G\) and \(E\):
Substituting these expressions into the difference-in-differences cancels the intercept and both main-effect terms. The only remaining term is the coefficient of the product:
This identity is exact for the stated mean model. With a binary \(G\) and binary \(E\), the model has one parameter for each of the four combinations, so it can represent any four group means. If the model is fit by ordinary least squares with an intercept and all three terms \(G\), \(E\), and \(GE\), its fitted group means are the four sample group means when all four groups are observed. Thus the estimated product coefficient is the sample difference-in-differences, even if the group sample sizes are unequal.
Worked Example: Calculating the Contrast From Four Means
Suppose a hypothetical study records a continuous trait in units (u) for two genotype groups and two exposure levels. The group means are \(10.0\) u for \(G=0,E=0\), \(13.0\) u for \(G=0,E=1\), \(12.0\) u for \(G=1,E=0\), and \(18.0\) u for \(G=1,E=1\). Calculate the additive interaction contrast.
First calculate the exposure-associated mean difference within each genotype group:
The difference between these differences is \(6.0-3.0=3.0\) u. Using the four-mean formula gives the same result:
In a linear model using zero-one coding, the estimated product-term coefficient is therefore \(3.0\) u. Descriptively, the mean difference between exposure levels is 3.0 u larger in genotype group 1 than in genotype group 0. These hypothetical group means alone do not show that exposure causes the trait difference.
Assumptions and Interpretation
The algebraic equality depends on the coding and the model, rather than on a special distribution for the outcome. It does not require normally distributed outcomes to define the contrast. For the equality between a fitted coefficient and the contrast of sample means, the model must include an intercept, both main effects, and their product, and all four genotype-exposure groups must be represented. The coefficient is then a description of those four fitted means.
If a model imposes additional restrictions—for example, it omits the product term—its fitted means cannot generally reproduce all four observed group means. The resulting fitted values may still be useful for a different purpose, but their contrast is not evidence that the observed four-mean contrast is zero. Likewise, if some genotype-exposure combinations have no observations, their means are not directly estimated from data without additional modeling assumptions.
A descriptive difference-in-differences is not automatically a causal interaction. A causal interpretation requires a suitable design and assumptions that make the relevant comparisons informative about outcomes under alternative exposure conditions. In observational data, for example, differences in other characteristics across exposure groups may contribute to the contrast. Model adjustment can address specified covariates under a chosen model, but it does not by itself guarantee that confounding has been removed.
The outcome scale matters. A contrast of means in the original trait units answers an additive-scale question. Transforming the outcome, or modeling a different quantity such as a risk, changes the scale and potentially the meaning of the interaction. Keep the outcome definition and units explicit when reporting the contrast.
Worked Example: Verifying the Coefficient by Substitution
Consider a hypothetical linear mean model for a quantitative trait measured in points:
where \(G\) and \(E\) are zero-one indicators. Substitution gives the four fitted means:
The exposure-associated mean difference is \(56-50=6\) points for \(G=0\), and \(58-54=4\) points for \(G=1\). Thus the difference-in-differences is \(4-6=-2\) points. Directly,
The product-term coefficient is \(\beta_{GE}=-2\), matching the contrast. The negative sign means that the exposure-associated mean difference is 2 points smaller in genotype group 1 than in genotype group 0 in this model. It does not mean that the outcome itself is negative.
When the Coding Uses a Different Scale
The numerical value of a coefficient depends on how the variables are coded. Suppose the two genotype groups are assigned numeric values \(g_0\) and \(g_1\), and the two exposure levels are assigned \(e_0\) and \(e_1\). In a model containing an intercept, both main effects, and the product \(GE\), the mean contrast still follows a simple rule: it is the product-term coefficient multiplied by the change in genotype code and the change in exposure code.
This follows because the intercept and terms involving only \(G\) or only \(E\) cancel in the four-mean contrast. The remaining product term contributes \(\beta_{GE}(g_1e_1-g_1e_0-g_0e_1+g_0e_0)\), which factors as \(\beta_{GE}(g_1-g_0)(e_1-e_0)\). Zero-one coding makes both code differences equal to 1, giving the earlier result. With other coding, divide the mean contrast by both code differences to obtain the coefficient on that coding scale.
Worked Example: Rescaling the Genotype Code
Suppose two hypothetical genotype groups are coded \(G=0\) and \(G=2\), while exposure is coded \(E=0\) and \(E=1\). The four group means of a trait measured in units (u) are \(\mu_{00}=20\) u, \(\mu_{01}=24\) u, \(\mu_{20}=25\) u, and \(\mu_{21}=32\) u. Calculate the mean contrast and the product-term coefficient for these codes.
The difference-in-differences is
Here the genotype code difference is \(2-0=2\), and the exposure code difference is \(1-0=1\). Therefore the coefficient for the \(G\times E\) product is
The contrast across the two specified genotype and exposure levels remains 3 u. The coefficient is 1.5 because it is expressed per unit of the chosen numeric codes. If the genotype groups were instead coded 0 and 1, the corresponding product coefficient would be 3 u. A coefficient’s numerical value should therefore be reported with its coding scheme.
Common Mistake
- Wrong reasoning: “The exposure-associated difference is 6 u in one genotype group and 3 u in the other, so the interaction is their average, 4.5 u.” Averaging the two differences does not compare them.
- Correction: Additive interaction is the difference between the two exposure-associated differences. In that example it is \(6-3=3\) u, with the subtraction order stated. Equivalently, calculate the four-mean contrast with the matching signs.
- Wrong reasoning: “A nonzero contrast proves the exposure has a causal effect that differs by genotype.” A nonzero contrast establishes a difference in observed or modeled mean differences; causal interpretation needs additional assumptions.
Check Your Understanding
Use the four-mean definition and pay attention to the coding and units.
- For means \(\mu_{00}=8\), \(\mu_{01}=11\), \(\mu_{10}=10\), and \(\mu_{11}=14\) points, calculate the additive interaction contrast.
- In zero-one coding, why do the intercept and both main-effect terms cancel from the difference-in-differences?
- If genotype codes are 1 and 3, exposure codes are 0 and 1, and the product coefficient is 2 points per genotype-code unit per exposure-code unit, what is the four-mean contrast?
- What does a negative additive interaction contrast say about the two exposure-associated mean differences?
- Why is a nonzero contrast in observational group means not, by itself, proof of causal effect modification?