Skip to content
Statistical RethinkingStatistical Rethinking

5.2 Masked relationship

Sometimes a real association is hidden because a confounding variable suppresses the relationship. Adding the right variable to the model can reveal an effect that was masked in the raw data. This is the opposite of a spurious association.

5.2.1 The milk energy example

The classic example uses data on milk energy content across primate species. The question: does body mass (MM) affect milk energy (KK)? The bivariate association is weak, but adding brain size (BB) reveals a strong negative effect of mass.

The causal story:

M→KM \rightarrow K (negative: larger animals produce less energy-dense milk) M→BM \rightarrow B (positive: larger animals have larger brains) B→KB \rightarrow K (positive: larger brains require more energy-dense milk)

The effect of MM on KK is masked because MM has both a direct negative effect on KK and an indirect positive effect through BB. The total effect is near zero, but the direct effect is strongly negative.

# Simulate the milk energy data
set.seed(42)
n_species <- 30

# Body mass (log scale)

mass <- rnorm(n_species, mean = 3, sd = 1)

# Brain size is positively influenced by mass

brain <- 0.7 * mass + rnorm(n_species, sd = 0.5)

# Milk energy: negatively influenced by mass, positively by brain

energy <- -0.5 _ mass + 0.6 _ brain + rnorm(n_species, sd = 0.3)

# Standardize

mass_s <- (mass - mean(mass)) / sd(mass)
brain_s <- (brain - mean(brain)) / sd(brain)
energy_s <- (energy - mean(energy)) / sd(energy)

# Bivariate: energy ~ mass

m_biv <- lm(energy_s ~ mass_s)
cat("Bivariate (energy ~ mass):\n")
cat(" beta_mass:", round(coef(m_biv)[2], 3), "\n")

# Multivariate: energy ~ mass + brain

m_multi <- lm(energy_s ~ mass_s + brain_s)
cat("\nMultivariate (energy ~ mass + brain):\n")
cat(" beta_mass:", round(coef(m_multi)[2], 3), "\n")
cat(" beta_brain:", round(coef(m_multi)[3], 3), "\n")

cat("\nThe mass effect is masked in the bivariate model\n")
cat("but revealed in the multivariate model.\n")
Click Run to execute this code in your browser with WebR

5.2.2 Why the relationship is masked

The bivariate coefficient of mass on energy is near zero because the total effect combines a direct negative effect and an indirect positive effect:

total effect=direct effect+indirect effect\text{total effect} = \text{direct effect} + \text{indirect effect} total effect=(−0.5)+(0.7×0.6)=−0.5+0.42=−0.08\text{total effect} = (-0.5) + (0.7 \times 0.6) = -0.5 + 0.42 = -0.08

The indirect path (M→B→KM \rightarrow B \rightarrow K) nearly cancels the direct path (M→KM \rightarrow K). But when we include brain size in the regression, we block the indirect path, and the direct effect is revealed.

# Visualize the masked relationship
par(mfrow = c(1, 3))

# Bivariate: energy vs mass (weak)

plot(mass_s, energy_s, pch = 16, col = "steelblue",
xlab = "Body mass (standardized)", ylab = "Milk energy (standardized)",
main = sprintf("Bivariate: beta = %.3f", coef(m_biv)[2]))
abline(m_biv, lwd = 2, col = "firebrick")

# Bivariate: energy vs brain (strong)

m_brain <- lm(energy_s ~ brain_s)
plot(brain_s, energy_s, pch = 16, col = "steelblue",
xlab = "Brain size (standardized)", ylab = "Milk energy (standardized)",
main = sprintf("Bivariate: beta = %.3f", coef(m_brain)[2]))
abline(m_brain, lwd = 2, col = "firebrick")

# Coefficient comparison

barplot(c(coef(m_biv)[2], coef(m_multi)[2]),
names.arg = c("Bivariate", "Multivariate"),
col = c("steelblue", "firebrick"), border = "white",
main = "Mass effect: masked vs revealed",
ylab = "Coefficient")
abline(h = 0, lty = 2)

par(mfrow = c(1, 1))
Click Run to execute this code in your browser with WebR

5.2.3 The causal graph

The masked relationship arises because the causal graph has two paths from mass to energy:

  1. Direct path: M→KM \rightarrow K (negative)
  2. Indirect path: M→B→KM \rightarrow B \rightarrow K (positive)

The total effect (bivariate coefficient) is the sum of both paths. The direct effect (multivariate coefficient) blocks the indirect path by conditioning on BB.

Rethinking

Adding variables can reveal or hide effects. The masked relationship shows that adding a variable can increase the apparent effect of another variable, while the spurious association shows that adding a variable can decrease it. The direction depends on the causal graph. This is why model selection must be guided by causal reasoning, not by statistical significance or automated procedures. A variable that seems irrelevant in a bivariate model may be crucial in a multivariate model, and vice versa.

Summary of Section 5.2

  • A masked relationship occurs when a confounder suppresses the association between a predictor and an outcome.
  • The total effect combines direct and indirect effects, which may cancel each other.
  • Adding the confounder to the model blocks the indirect path and reveals the direct effect.
  • The milk energy example shows that body mass has a strong negative direct effect on milk energy, masked by the positive indirect path through brain size.
  • Model selection must be guided by causal reasoning, not by statistical significance.