18  Geometry of Causal Inference

Let no one ignorant of geometry enter here.
(inscription above the entrance to Plato’s Academy, circa 387 BC)

While algebra is useful and often definitive, a geometric perspective can be a more useful guide to intuition. A geometrical perspective on causal inference first proposed in Rothman (1975) clarifies the relationships between confounding, effect measure modification, and collapsibility (Kenah 2024). Through the lens of regression models, these concepts blend together almost inextricably. Through the lens of standardization and geometry, the distinctions between them are clear.

18.1 Rothman diagrams

The unit square is the set of all ordered pairs \((x, y) \in \mathbb{R}^2\) where both \(x\) and \(y\) are in the interval \([0, 1]\) (i.e., the interval including zero, one, and all real numbers in between). To represent the point \((x, y)\), we can plot \(x\) on a horizontal axis (the x-axis) and \(y\) on a vertical axis (the y-axis). Rothman (1975) introduced a geometric perspective on causal inference where \(x\) represents the risk of disease in the unexposed or untreated and \(y\) represents the risk of disease in the exposed or treated. A similar plot was introduced by L’Abbé, Detsky, and O’Rourke (1987) for meta-analysis, and these L’Abbé plots were used by Richardson, Robins, and Wang (2017) to discuss the estimation of risk differences and risk ratios.

18.1.1 Example: smoking and 20-year mortality

As an illustration, we will use an example of confounding given by Appleton, French, and Vanderpump (1996). It occurred in a cohort of women who participated in a study of thyroid and heart disease in Newcastle upon Tyne, United Kingdom in 1972-1974 (Tunbridge et al. 1977). Their smoking status was measured in the original study, and their 20-year survival status was measured in a follow-up study (Vanderpump et al. 1995). Table 18.1 shows the crude 2x2 table for smoking and 20-year mortality.

Table 18.1: Crude 2x2 table for smoking status in the original study and 20-year mortality.
Dead Alive Total
Smoker 139 443 582
Nonsmoker 230 502 732
Total 369 945 1,314

Table 18.2 shows the corresponding crude measures of association estimated using binomial generalized linear models (GLMs). Binomial GLMs used the logit link for the odds ratio, the log link for the risk ratio, the identity link for the risk difference, and the complementary log-log link for the cumulative hazard ratio. Smokers had lower 20-year mortality than nonsmokers, and this difference was statistically significant. The binomial GLMs produced a likelihood ratio p-value of 0.0024. A Pearson chi-squared test (which is the score test) produces a p-value of 0.0025, and a Fisher’s exact test produces a p-value of 0.0029 with 95% confidence limits of (0.531, 0.882) for the odds ratio.

Table 18.2: Crude measures of association for smoking and 20-year mortality with likelihood ratio confidence limits and p-value (which does not depend on the measure of association).
Estimate 95% confidence interval p-value
Odds ratio 0.685 (0.535, 0.875) 0.0024
Risk ratio 0.760 (0.633, 0.908) 0.0024
Risk difference -0.075 (-0.123, -0.027) 0.0024
Cumulative hazard ratio 0.724 (0.584, 0.892) 0.0024

Table 18.3 shows 2x2 tables stratified by age at the time of the original survey adapted from Appleton, French, and Vanderpump (1996). Older participants were less likely to smoke but more likely to die within 20 years than younger participants. Among those aged 18-64 years, the prevalence of smoking was \(533 / 1{,}072 \approx 0.497\) and the risk of death was \(162 / 1{,}072 \approx 0.151\). Among those aged \(\geq 65\) years, the prevalence of smoking was \(49 / 242 \approx 0.202\) and the risk of death was \(207 / 242 \approx 0.855\). The difference in survival between smokers and nonsmokers was due in part to different age distributions, so the causal effect of smoking on 20-year mortality was confounded by age.

Table 18.3: Age-stratified 2x2 tables for smoking and 20-year mortality.
18-64 years Dead Alive Total
Smoker 97 436 533
Nonsmoker 65 474 539
Total 162 910 1,072
65+ years Dead Alive Total
Smoker 42 7 49
Nonsmoker 165 28 193
Total 207 35 242
rothman-glm.R
## Binomial GLM analysis of smoking and 20-year mortality

# load R packages
library(dplyr)      # for case_when()
library(lmtest)     # for lrtest()

# data from Appleton et al. (The American Statistician, 1996)
# Using an ordered factor allows the use of <, =, and > for comparison.
agegroups <- factor(c("18-24", "25-34", "35-44", "45-54", "55-64",
                      "65-74", "75+"),
                    ordered = TRUE)
AFVdat <- data.frame(smoking = rep(c(0, 0, 1, 1), times = length(agegroups)),
                     death = rep(c(0, 1, 0, 1), times = length(agegroups)),
                     age = rep(agegroups, each = 4))
AFVrows <- rep(seq_len(nrow(AFVdat)),
               times = c(61, 1, 53, 2, 152, 5, 121, 3, 114, 7, 95, 14, 66, 12,
                         103, 27, 81, 40, 64, 51, 28, 101, 7, 29, 0, 64, 0, 13))
AFVdat <- AFVdat[AFVrows, ]
AFVdat$binage <- case_when(AFVdat$age < "65-74" ~ "18-64",
                           AFVdat$age >= "65-74" ~ "65+")

# crude 2x2 table and hypothesis tests
twobytwo <- function(covariate = NULL, dat = AFVdat) {
  # generate crude or stratified 2x2 tables
  # covariate should be a string naming a variable in dat
  formla <- "~ smoking + death"
  # update formula if there is a covariate specified
  if (!is.null(covariate)) formla <- paste(formla, "+", covariate)
  tab22 <- xtabs(formla, data = dat, drop.unused.levels = TRUE)
  # format stratified 2x2 tables into a list
  if (length(dim(tab22)) > 2) {
    tab22 <- unlist(apply(tab22, 3, list), recursive = FALSE)
  } else {
    tab22 <- list(tab22)
  }
  # reorder rows and columns and add margins to 2x2 table(s)
  lapply(tab22, function(x) addmargins(x[c(2, 1), ][, c(2, 1)]))
}

# crude 2x2 table and hypothesis tests
crude22 <- twobytwo()[[1]]
crude22_nomarg <- crude22[-3, -3]             # remove margins
chisq.test(crude22_nomarg, correct = FALSE)   # Pearson chi-squared test
fisher.test(crude22_nomarg)                   # Fisher's exact test

# crude measures of association
mest <- function(model, pval = TRUE, ...) {
  # extract point and interval estimates from GLM
  meas <- coef(model)["smoking"]
  ci <- confint(model, ...)["smoking", ]
  # get risk/odds ratio point and interval estimates from their logarithms
  if (model$family$link %in% c("log", "logit", "cloglog")) {
    meas <- exp(meas)
    ci <- exp(ci)
  }
  if (pval == FALSE) {
    return(c(meas, ci[1], ci[2]))
  } else {
    # likelihood ratio p-value (to match likelihood ratio confidence limits)
    pval <- lrtest(model, "smoking")[2, "Pr(>Chisq)"]
    c(meas, ci[1], ci[2], pval = pval)
  }
}
# binomial GLMs for odds ratio, risk ratio, and risk difference
crude_logistic <- glm(death ~ smoking, data = AFVdat,
                      family = binomial(link = "logit"))
crude_logbinom <- glm(death ~ smoking, data = AFVdat,
                      family = binomial(link = "log"))
crude_idbinom <- glm(death ~ smoking, data = AFVdat,
                     family = binomial(link = "identity"))
crude_chrbinom <- glm(death ~ smoking, data = AFVdat,
                      family = binomial(link = "cloglog"))
crude_meas <- do.call(rbind, lapply(list(oddsratio = crude_logistic,
                                         riskratio = crude_logbinom,
                                         riskdiff = crude_idbinom,
                                         chazratio = crude_chrbinom),
                                    mest))

## 2x2 tables stratified by age
strat2 <- twobytwo("binage")

18.1.2 Causal points

Let \(X\) be a binary exposure or treatment, \(D\) be a binary disease outcome, and \(C\) be a binary covariate that is not causally affected by \(X\). Let \(D^x\) be the potential disease outcome when we intervene to set \(X = x\) (Rubin 1974). The exposure, outcome, and covariate of individual \(i\) are \(X_i\), \(D_i\), and \(C_i\), respectively. The potential outcome of \(i\) under an intervention that sets \(X_i = x\) is \(D^x_i\). If \(X_i = x\), then \(D_i = D^x_i\) by consistency of potential outcomes (Pearl 2009).

In our example, \(X\) is smoking status at the time of the original survey, \(D\) is death within 20 years, and \(C\) is age. The potential outcome \(D^1\) is death within 20 years as a smoker, and \(D^0\) is death within 20 years as a nonsmoker. By consistency, \(D = D^1\) for smokers and \(D = D^0\) for nonsmokers. We see only one of the two potential outcomes for each individual.

Probabilities are defined by proportions of the underlying population. For example, \(\Pr(X = x, C = c)\) is the proportion of the population with \(X = x\) and \(C = c\). Conditional probabilities are defined by proportions of subpopulations. For example, \(\Pr(X = x \given{} C = c)\) is the proportion of the subpopulation with \(C = c\) that has \(X = x\). Probabilities and conditional probabilities can estimated using a sample of \(n\) individuals from the population, with uncertainty due to sampling variation summarized in terms of frequentist confidence intervals or Bayesian credible intervals. In our example, the study participants can be seen as a sample of size \(n = 1{,}314\) from the population of women in the United Kingdom between 1972 and 1974. For simplicity, we will assume no selection bias and ignore sampling variation whenever possible.

The causal risk of disease when we intervene to set \(X = 1\) is \(\Pr(D^1 = 1)\), and the causal risk of disease when we set \(X = 0\) in the entire population is \(\Pr(D^0 = 1)\). The point \[ \pmarg = \Big(\Pr(D^0 = 1), \Pr(D^1 = 1)\Big) \tag{18.1}\] on the Rothman diagram is the marginal causal point for the population. It is causal because it is based on causal risks of disease under intervention, and it is marginal because it ignores the covariate \(C\).

In the subpopulation with \(C = c\), the causal risk of disease when we set \(X = x\) is: \[ \Pr(D^x = 1 \given{} C = c) = \frac{\Pr(D^x = 1, C = c)}{\Pr(C = c)} \] The point \[ p_c = \Big(\Pr\bigl(D^0 = 1 \given{} C = c\bigr), \Pr\bigl(D^1 = 1 \given{} C = c\bigr)\Big) \] on the Rothman diagram is the stratum-specific causal point for the subpopulation with \(C = c\).

In practice, we are almost always missing the data needed to plot causal points on a Rothman diagram. To draw marginal or stratum-specific causal points, we need both potential outcomes \(D^1_i\) and \(D^0_i\) for each individual \(i\) in our sample. In our example, we would need to know whether the smokers would have survived for 20 years had they been nonsmokers and whether the nonsmokers would have survived for 20 years had they been smokers.

18.1.3 Association points

Unlike causal points, we can plot association points using data on the eligible population. The risk of disease among the unexposed is \(\Pr(D = 1 \given{} X = 0)\), and the risk of disease among the exposed is \(\Pr(D = 1 \given{} X = 1)\). The point \[ \pcrude = \Big(\Pr(D = 1 \given{} X = 0), \Pr(D = 1 \given{} X = 1)\Big) \] on the Rothman diagram is the crude association point for the population, which is approximated by the crude association point for the study sample. Figure 18.1 shows the crude point for the data from Table 18.1. Its x-coordinate is the risk of death among nonsmokers, which is \(230 / 702 \approx 0.314\). Its y-coordinate is the risk of death among smokers, which is \(139 / 582 \approx 0.239\). The null line is the set of all points where the risks of death in the unexposed and the exposed are equal. It is a diagonal line from the point \((0, 0)\) to the point \((1, 1)\).

The conditional risk of disease given \(X = x\) and \(C = c\) in the eligible population is \[ \Pr(D = 1 \given{} X = x, C = c) = \frac{\Pr(D = 1, X = x, C = c)}{\Pr(X = x, C = c)}. \] The point \[ p^*_c = \Big(\Pr(D = 1 \given{} X = 0, C = c), \Pr(D = 1 \given X = 1, C = c)\Big) \] is the stratum-specific association point for the subpopulation with \(C = c\). There is one stratum-specific association point for each value of \(C\). Figure 18.1 shows the stratum-specific association points for the age groups in Table 18.3. For both smokers and nonsmokers, the risks of death were much higher in the older age stratum, and these differences in mortality due to age were much larger than the differences due to smoking.

When conditioning on \(C\) controls confounding of the causal effect of \(X\) on \(D\), exchangeability given \(C\) and consistency guarantee that \[ \begin{aligned} \Pr(D^x = 1 \given{} C = c) &= \Pr(D^x = 1 \given{} X = x, C = c) \\ &= \Pr(D = 1 \given{} X = x, C = c) \end{aligned} \tag{18.2}\] for \(x = 0\) and \(x = 1\) (Pearl 2009; Hernán and Robins 2023). Thus, the causal and association points are the same (up to random variation) within each stratum of \(C\). In our example, the stratum-specific association points represent stratum-specific causal points if stratifying into the 18-64 and 65+ year age groups removes all confounding of the association between smoking and 20-year survival. In reality, there is likely to be residual confounding by age within these groups. Better control of confounding could be achieved with a larger number of age groups or a well-chosen regression model.

Pretending that we can plot association points for the eligible population has allowed us to ignore selection bias. When we have data only from a sample of this population, we need \[ \Pr(D = 1 \given{} C = c, X = x, S = 1) = \Pr(D = 1 \given{} C = c, X = x). \] If the analytic cohort condition holds, both sides are equal to \(\Pr(D^x = 1 \given{} C = c)\) by equations Equation 17.8 (for the left-hand side) and Equation 18.2 (for the right-hand side). Under the analytic cohort condition, the association points for the study sample match the association points for the eligible population up to sampling variation, which is accounted for in both Bayesian and frequentist inference. Focusing on association points in the eligible population helps us isolate confounding from selection bias.

18.1.4 Standardization and line segments

If we have two points \(p_0 = (x_0, y_0)\) and \(p_1 = (x_1, y_1)\) in \(\mathbb{R}^2\), we can multiply them by scalars and add them like vectors to get another point in \(\mathbb{R}^2\): \[ a_0 p_0 + a_1 p_1 = \big(a_0 x_0 + a_1 x_1, a_0 y_0 + a_1 y_1\big). \] As time \(t\) goes from zero to one, the point \[ p(t) = (1 - t) p_0 + t p_1 \] traces the line segment from \(p_0\) to \(p_1\). This line segment is the set \[ \big\{(x, y) \in \mathbb{R}^2: (x, y) = (1 - t) p_0 + t p_1 \text{ for some } t \in [0, 1]\big\}, \tag{18.3}\] which is the set of all points \(p(t)\) that we cross while going from \(p_0\) to \(p_1\) in a straight line.

Because \(C\) is not causally affected by \(X\), \(\Pr(C = 0)\) and \(\Pr(C = 1)\) remain the same no matter how we intervene to set \(X\). For any possible value \(x\) of \(X\), \[ \begin{aligned} \Pr(D^x = 1) &= \Pr(D^x = 1 \given{} C = 0) \Pr(C = 0) \\ &\qquad + \Pr(D^x = 1 \given{} C = 1) \Pr(C = 1) \end{aligned} \tag{18.4}\] by the law of total probability. If \(p_0\) and \(p_1\) are the stratum-specific causal points for \(C = 0\) and \(C = 1\), then \[ \pmarg = p_0 \Pr(C = 0) + p_1 \Pr(C = 1). \] Because \(\Pr(C = 0) + \Pr(C = 1) = 1\), the marginal causal point is on the line segment connecting the stratum-specific causal points. Other points on this line segment are marginal causal points for populations with the same stratum-specific causal points but different distributions of \(C\). For example, the point \(0.5 p_0 + 0.5 p_1\) halfway between \(p_0\) and \(p_1\) is the marginal causal point for a population where \(\Pr(C = 1) = 0.5\).

With association points, line segments correspond to standardized risks of disease Kenah (2024). The standardized risk of disease given \(X = x\) is the marginal risk of disease in a hypothetical standard population where the prevalence of \(C = 1\) equals \(\Prstd(C = 1)\). The standardized risk of disease under \(X = x\) is \[ \begin{aligned} \Prstd(D = 1 \given{} X = x) &= \Pr(D = 1 \given{} X = x, C = 0) \Prstd(C = 0) \\ &\qquad + \Pr(D = 1 \given{} X = x, C = 1) \Prstd(C = 1). \end{aligned} \tag{18.5}\] Standardization allows us to calculate marginal risks of disease using the same distribution of \(C\) for both exposure groups, which removes confounding by \(C\). The corresponding standardized association point \[ \begin{aligned} p^*_\std &= \big(\Prstd(D = 1 \given{} X = 0), \Prstd(D = 1 \given{} X = 1)\big) \\ &= p^*_0 \Prstd(C = 0) + p^*_1 \Prstd(C = 1) \end{aligned} \] is on the line segment connecting the stratum-specific points \(p^*_0\) and \(p^*_1\). Each point on this standardized segment represents a standardized association point for some standard population. For example, the point \(0.5 p^*_0 + 0.5 p^*_1\) corresponds to a standard population with \(\Prstd(C = 1) = 0.5\).

If there is no unmeasured confounding of the causal effect of \(X\) on \(D\) within strata of \(C\) and \(\Prstd(C = 1) = \Pr(C = 1)\), then \[ p^*_\std = p_0 \Pr(C = 0) + p_1 \Pr(C = 1) = \pmarg. \] so the standardized point equals the marginal causal point (up to sampling variation). If we standardize to any other distribution of \(C\), we get the marginal causal point for the corresponding standard population.

In our example, there are 1,072 women aged 18-64 years and 242 women aged 65+ years at the time of the original survey. Using this age distribution, the standardized risk of death among smokers is \[ \bigg(\frac{1{,}072}{1{,}314} \times \frac{97}{533}\bigg) + \bigg(\frac{242}{1{,}314} \times \frac{42}{49}\bigg) \approx 0.306 \] and the standardized risk of death among nonsmokers is \[ \bigg(\frac{1{,}072}{1{,}314} \times \frac{65}{539}\bigg) + \bigg(\frac{242}{1{,}314} \times \frac{165}{193}\bigg) \approx 0.256. \] This standardized point is plotted in Figure 18.1 with the label “All ages”. If stratifying by age has controlled confounding of the causal effect of smoking on 20-year mortality, the x-coordinate of this point is the causal risk of death in the study sample if we had intervened to make all participants nonsmokers, and its y-coordinate is the causal risk of death if we had intervened (unethically) to make all participants smokers.

Among the 582 smokers in the study sample, there are 533 women aged 18-64 years and 49 women aged 65+ years. Using this age distribution, the standardized risk of death among smokers is \[ \bigg(\frac{533}{582} \times \frac{97}{533}\bigg) + \bigg(\frac{49}{582} \times \frac{42}{49}\bigg) = \frac{97 + 42}{582} \approx 0.239, \] which is just the marginal risk of death among smokers in the sample. The corresponding standardized risk of death among nonsmokers is \[ \bigg(\frac{533}{582} \times \frac{65}{539}\bigg) + \bigg(\frac{49}{582} \times \frac{165}{193}\bigg) \approx 0.182. \] This point is plotted in Figure 18.1. It has the same y-coordinate as the crude point because of consistency: Because we see \(D^1\) for smokers, their actual risk of death equals their risk of death under an intervention that makes them smokers. If stratifying by age has controlled confounding, the x-coordinate of this point is the counterfactual risk of death among smokers had we intervened to make them nonsmokers. Compared to the standardized point for the study sample, the point for smokers is closer to the stratum-specific point for the 18-64 year age group because smokers were younger on average.

Among the 732 nonsmokers, there are 539 women aged 18-64 years and 193 women aged \(\geq 65\) years. Figure 18.1 shows the standardized point for this age distribution, which has the same x-coordinate as the crude point because of consistency (i.e., we see \(D^0\) for nonsmokers). If stratifying by age has controlled confounding, then the y-coordinate of this point is the counterfactual risk of death among nonsmokers had we intervened to make them smokers. Compared to the standardized points for smokers and for the study sample, the point for nonsmokers is closer to the stratum-specific point for the 65+ year age group because nonsmokers were older on average.

Code
rothman-std.R
## Rothman diagram for smoking and 20-year mortality

# load R packages
library(dplyr)   # for case_when()
library(lmtest)  # for lrtest()

# data from Appleton et al. (The American Statistician, 1996)
# Using an ordered factor allows the use of <, =, and > for comparison.
agegroups <- factor(c("18-24", "25-34", "35-44", "45-54", "55-64",
                      "65-74", "75+"),
                    ordered = TRUE)
AFVdat <- data.frame(smoking = rep(c(0, 0, 1, 1), times = length(agegroups)),
                     death = rep(c(0, 1, 0, 1), times = length(agegroups)),
                     age = rep(agegroups, each = 4))
AFVrows <- rep(seq_len(nrow(AFVdat)),
               times = c(61, 1, 53, 2, 152, 5, 121, 3, 114, 7, 95, 14, 66, 12,
                         103, 27, 81, 40, 64, 51, 28, 101, 7, 29, 0, 64, 0, 13))
AFVdat <- AFVdat[AFVrows, ]
AFVdat$binage <- case_when(AFVdat$age < "65-74" ~ "18-64",
                           AFVdat$age >= "65-74" ~ "65+")

# 2x2 tables
twobytwo <- function(covariate = NULL, dat = AFVdat) {
  # generate crude or stratified 2x2 tables
  # covariate should be a string naming a variable in dat
  formla <- "~ smoking + death"
  # update formula if there is a covariate specified
  if (!is.null(covariate)) formla <- paste(formla, "+", covariate)
  tab22 <- xtabs(formla, data = dat, drop.unused.levels = TRUE)
  # format stratified 2x2 tables into a list
  if (length(dim(tab22)) > 2) {
    tab22 <- unlist(apply(tab22, 3, list), recursive = FALSE)
  } else {
    tab22 <- list(tab22)
  }
  # reorder rows and columns and add margins to 2x2 table(s)
  lapply(tab22, function(x) addmargins(x[c(2, 1), ][, c(2, 1)]))
}
strat2 <- twobytwo("binage")

# risk calculations
condrisk <- function(covariate = NULL, dat = AFVdat) {
  # function to calculate crude or stratified risks in smokers and nonsmokers
  # covariate should be a string naming a variable in dat
  strat2 <- twobytwo(covariate, dat)
  risk <- function(v) v[, 1] / v[, 3]   # v = (alive, dead)
  risks <- do.call(rbind, lapply(strat2, risk))
  colnames(risks) <- c("smokers", "nonsmokers", "marginal")
  as.data.frame(risks)
}
margrisk <- condrisk()
stratrisk2 <- condrisk("binage")

# standardized risks of death over binary age groups
# all participants
binage_n <- sapply(strat2, function(x) x[3, 3])
binage_p <- binage_n / sum(binage_n)
stdrisk2_all <- data.frame(smokers = sum(stratrisk2$smokers * binage_p),
                           nonsmokers = sum(stratrisk2$nonsmokers * binage_p))
# smokers
binage_nsmk <- sapply(strat2, function(x) x[1, 3])
binage_psmk <- binage_nsmk / sum(binage_nsmk)
stdrisk2_smk <- data.frame(smokers = sum(stratrisk2$smokers * binage_psmk),
                           nonsmokers = sum(stratrisk2$nonsmokers
                                            * binage_psmk))
# nonsmokers
binage_nnon <- sapply(strat2, function(x) x[2, 3])
binage_pnon <- binage_nnon / sum(binage_nnon)
stdrisk2_non <- data.frame(smokers = sum(stratrisk2$smokers * binage_pnon),
                           nonsmokers = sum(stratrisk2$nonsmokers
                                            * binage_pnon))


# Rothman diagram with standardized segment
xlabel <- "Risk of death among the unexposed (nonsmokers)"
ylabel <- "Risk of death among the exposed (smokers)"
rothdiagram2 <- function(labels = c("18-64 (0%)", "65+ (100%)")) {
  # function to plot Rothman diagram with crude and stratum-specific points
  plot(margrisk$nonsmokers, margrisk$smokers, asp = 1,
       xlim = c(0, 1), ylim = c(0, 1), xlab = xlabel, ylab = ylabel)
  segments(0, 0, 1, 1, col = "darkgray")
  points(stratrisk2$nonsmokers, stratrisk2$smokers, pch = 19)
  grid()
  text(margrisk$nonsmokers + 0.01, margrisk$smokers - 0.02, adj = c(0, 1),
       labels = "Crude point")
  text(stratrisk2["18-64", ]$nonsmokers - 0.01,
       stratrisk2["18-64", ]$smokers + 0.02,
       adj = c(1, 0), labels = labels[1])
  text(stratrisk2["65+", ]$nonsmokers - 0.01,
       stratrisk2["65+", ]$smokers + 0.02,
       adj = c(1, 0), labels = labels[2])
  text(0.1, 0.06, srt = 45, col = "darkgray", labels = "Null line")
}
rothdiagram2()
text(margrisk$nonsmokers + 0.01, margrisk$smokers - 0.06, adj = c(0, 1),
     labels = "(nonsmokers 26% 65+, smokers 8% 65+)")
segments(stratrisk2$nonsmokers[1], stratrisk2$smokers[1],
         stratrisk2$nonsmokers[2], stratrisk2$smokers[2], lty = "solid")
text(0.56, 0.62, srt = 42, labels = "Standardized segment")
points(stdrisk2_non$nonsmokers, stdrisk2_non$smokers)
text(stdrisk2_non$nonsmokers - 0.01, stdrisk2_non$smokers + 0.02, adj = c(1, 0),
     labels = "Nonsmokers (26%)")
points(stdrisk2_all$nonsmokers, stdrisk2_all$smokers)
text(stdrisk2_all$nonsmokers - 0.01, stdrisk2_all$smokers + 0.02, adj = c(1, 0),
     labels = "All participants (18%)")
points(stdrisk2_smk$nonsmokers, stdrisk2_smk$smokers)
text(stdrisk2_smk$nonsmokers - 0.01, stdrisk2_smk$smokers + 0.02, adj = c(1, 0),
     labels = "Smokers (8%)")
Figure 18.1: A Rothman diagram with the crude association point (open circle), the age-stratified association points (solid circles), the standardized segment (black line), and three standardized points (open circles). Each point is labeled with the proportion of the standard population that is aged > 65 years.

18.2 Confounding

The set in Equation 18.3 is a line segment connecting \(p_0\) and \(p_1\) because we use the same \(t\) for both axes. If we allow different values of \(t\) for the two axes, we get the set \[ \begin{aligned} \big\{(x, y) \in \mathbb{R}^2 &: x = (1 - t_x) x_0 + t_x x_1 \text{ and } y = (1 - t_y) y_0 + t_y y_1 \\ &\quad \text{ for some } t_x, t_y \in [0, 1]\big\}, \end{aligned} \tag{18.6}\] which is a rectangle with sides parallel to the axes and corners at \(p_0\) and \(p_1\). It is called the circumscribing rectangle because it is the smallest rectangle with sides parallel to the axes that contains these points. The line segment in Equation 18.3 is a diagonal of this rectangle.

18.2.1 Confounding rectangle

The crude association point \(\pcrude\) has the same x-coordinate as the standardized point for the unexposed \[ p_0^* \Pr(C = 0 \given X = 0) + p_1^* \Pr(C = 1 \given X = 0), \] and it has the same y-coordinate as the standardized point for the exposed \[ p_0^* \Pr(C = 1 \given X = 0) + p_1^* \Pr(C = 1 \given X = 1). \] If the distribution of \(C\) is different in the unexposed and the exposed, then \(\pcrude\) will be off the standardized segment connecting \(p_0^*\) and \(p_1^*\) (unless they share an x-coordinate or a y-coordinate). However, it must be in the circumscribing rectangle with corners at \(p_0^*\) and \(p_1^*\) and sides parallel to the axes Kenah (2024). This is the confounding rectangle, and the standardized segment is one of its diagonals. In the limit of a large sample, the crude association point \(\pcrude\) is on the standardized segment connecting \(p_0^*\) and \(p_1^*\) if and only if the causal effect of \(X\) on \(D\) is not confounded by \(C\). Due to sampling variation, this equivalence is only approximate in practice.

Figure 18.2 shows a Rothman diagram with the confounding rectangle for the data in Table 18.3. The crude point is off the standardized segment because the age distributions for smokers and nonsmokers are different. The stratum-specific points define two corners of the rectangle. The other two corners represent the most extreme confounding possible given the stratum-specific risks of death in the exposed and unexposed. The large difference in the risk of death between the two age strata creates a large confounding rectangle that contains points far above and far below the null line. Thus, unmeasured confounding could create an association that exaggerates or reverses the causal effect of smoking on 20-year mortality.

Code
rothman-conf.R
## Rothman diagram for smoking and 20-year mortality

# load R packages
library(dplyr)      # for case_when()
library(plotrix)

# data from Appleton et al. (The American Statistician, 1996)
# Using an ordered factor allows the use of <, =, and > for comparison.
agegroups <- factor(c("18-24", "25-34", "35-44", "45-54", "55-64",
                      "65-74", "75+"),
                    ordered = TRUE)
AFVdat <- data.frame(smoking = rep(c(0, 0, 1, 1), times = length(agegroups)),
                     death = rep(c(0, 1, 0, 1), times = length(agegroups)),
                     age = rep(agegroups, each = 4))
AFVrows <- rep(seq_len(nrow(AFVdat)),
               times = c(61, 1, 53, 2, 152, 5, 121, 3, 114, 7, 95, 14, 66, 12,
                         103, 27, 81, 40, 64, 51, 28, 101, 7, 29, 0, 64, 0, 13))
AFVdat <- AFVdat[AFVrows, ]
AFVdat$binage <- case_when(AFVdat$age < "65-74" ~ "18-64",
                           AFVdat$age >= "65-74" ~ "65+")

# 2x2 tables
twobytwo <- function(covariate = NULL, dat = AFVdat) {
  # generate crude or stratified 2x2 tables
  # covariate should be a string naming a variable in dat
  formla <- "~ smoking + death"
  # update formula if there is a covariate specified
  if (!is.null(covariate)) formla <- paste(formla, "+", covariate)
  tab22 <- xtabs(formla, data = dat, drop.unused.levels = TRUE)
  # format stratified 2x2 tables into a list
  if (length(dim(tab22)) > 2) {
    tab22 <- unlist(apply(tab22, 3, list), recursive = FALSE)
  } else {
    tab22 <- list(tab22)
  }
  # reorder rows and columns and add margins to 2x2 table(s)
  lapply(tab22, function(x) addmargins(x[c(2, 1), ][, c(2, 1)]))
}
strat2 <- twobytwo("binage")

# risk calculations
condrisk <- function(covariate = NULL, dat = AFVdat) {
  # function to calculate crude or stratified risks in smokers and nonsmokers
  # covariate should be a string naming a variable in dat
  strat2 <- twobytwo(covariate, dat)
  risk <- function(v) v[, 1] / v[, 3]   # v = (alive, dead)
  risks <- do.call(rbind, lapply(strat2, risk))
  colnames(risks) <- c("smokers", "nonsmokers", "marginal")
  as.data.frame(risks)
}
margrisk <- condrisk()
stratrisk2 <- condrisk("binage")

# standardized risks of death over binary age groups
# all participants
binage_n <- sapply(strat2, function(x) x[3, 3])
binage_p <- binage_n / sum(binage_n)
stdrisk2_all <- data.frame(smokers = sum(stratrisk2$smokers * binage_p),
                           nonsmokers = sum(stratrisk2$nonsmokers * binage_p))
# smokers
binage_nsmk <- sapply(strat2, function(x) x[1, 3])
binage_psmk <- binage_nsmk / sum(binage_nsmk)
stdrisk2_smk <- data.frame(smokers = sum(stratrisk2$smokers * binage_psmk),
                           nonsmokers = sum(stratrisk2$nonsmokers
                                            * binage_psmk))
# nonsmokers
binage_nnon <- sapply(strat2, function(x) x[2, 3])
binage_pnon <- binage_nnon / sum(binage_nnon)
stdrisk2_non <- data.frame(smokers = sum(stratrisk2$smokers * binage_pnon),
                           nonsmokers = sum(stratrisk2$nonsmokers
                                            * binage_pnon))

# Rothman diagram with confounding rectangle
plot(margrisk$nonsmokers, margrisk$smokers, asp = 1,
     xlim = c(0, 1), ylim = c(0, 1),
     xlab = "Risk of death among the unexposed (nonsmokers)",
     ylab = "Risk of death among the exposed (smokers)")
segments(0, 0, 1, 1, col = "darkgray")
points(stratrisk2$nonsmokers, stratrisk2$smokers, pch = 19)
grid()
text(margrisk$nonsmokers + 0.01, margrisk$smokers - 0.02, adj = c(0, 1),
     labels = "Crude point")
text(stratrisk2["18-64", ]$nonsmokers - 0.01,
     stratrisk2["18-64", ]$smokers + 0.02,
     adj = c(1, 0), labels = "18-64 (0%)")
text(stratrisk2["65+", ]$nonsmokers - 0.01,
     stratrisk2["65+", ]$smokers + 0.02,
     adj = c(1, 0), labels = "65+ (100%)")
text(0.1, 0.06, srt = 45, col = "darkgray", labels = "Null line")
segments(stratrisk2["18-64", "nonsmokers"], stratrisk2["18-64", "smokers"],
         stratrisk2["65+", "nonsmokers"], stratrisk2["65+", "smokers"],
         lty = "solid")
text(0.48, 0.55, srt = 42, labels = "Standardized segment")
text(0.5, 0.83, labels = "Confounding rectangle")
polygon(rep(stratrisk2$nonsmokers, each = 2),
        c(stratrisk2$smokers, rev(stratrisk2$smokers)),
        lty = "dashed")
points(stratrisk2["18-64", "nonsmokers"], stratrisk2["65+", "smokers"])
text(stratrisk2["18-64", "nonsmokers"] + 0.01,
     stratrisk2["65+", "smokers"] + c(0.07, 0.03),
     labels = c("All nonsmokers 18-64,", "all smokers 65+"))
points(stratrisk2["65+", "nonsmokers"], stratrisk2["18-64", "smokers"])
text(stratrisk2["65+", "nonsmokers"],
     stratrisk2["18-64", "smokers"] - c(0.03, 0.07),
     labels = c("All nonsmokers 65+,", "all smokers 18-64"))
Figure 18.2: A Rothman diagram with the standardized segment (solid) and the confounding rectangle (dashed).

18.2.2 Confounders with more than two levels*

The generalization of the line segment in Equation 18.3 for \(k \geq 1\) points \(p_1, \ldots, p_k\) is the convex hull \[ \begin{aligned} \big\{(x, y) \in \mathbb{R}^2 &: (x, y) = w_1 p_1 + \ldots + w_k p_k \text{ for } w_1, \ldots w_k \geq 0 \\ & \quad \text{ such that } w_1 + \ldots + w_k = 1\big\}. \end{aligned} \tag{18.7}\] The convex hull is the set of all weighted sums of the points \(p_1, \ldots, p_k\) where the weights are nonnegative and add up to one. Geometrically, it is the shape you would get if you stretched a rubber band around all the points. It is convex because it contains the line segment joining any two of its points. If \(k = 1\), the convex hull is the point \(p_1\). If \(k = 2\), the convex hull is the line segment connecting \(p_1\) and \(p_2\).

Now suppose that \(C\) has \(k \geq 1\) possible values \(c_1, \ldots c_k\). Then we have \(k\) stratum-specific association points \(p_1^*, \ldots p_k^*\). The standardized segment is the convex hull for \(k = 2\) strata. For \(k > 2\) strata, we will call the convex hull of the stratum-specific points the standardized hull. Stratum-specific points can be in its interior or on its perimeter.

Figure 18.3 shows the standardized hull for the six age strata adapted from Appleton, French, and Vanderpump (1996). The point for the 45-54 year age group is in its interior, but all other stratum-specific points are on its perimeter. Almost all of the standardized hull is above the null line, where the risk of death for smokers is higher than the risk of death for nonsmokers.

For any \(k \geq 1\), we get a confounding rectangle. Using different sets of weights for the exposed and unexposed to calculate a possible crude point, we can get any point in the circumscribing rectangle for \(p_1^*, \ldots, p_k^*\). It has sides parallel to x-axis with y-coordinates at the smallest and largest stratum-specific risks in the exposed, and it has sides parallel to the y-axis with x-coordinates equal to the smallest and largest stratum-specific risks in the unexposed. It contains the entire standardized hull. Unlike the \(k = 2\) case, the confounding rectangle for \(k > 2\) does not necessarily have stratum-specific points at any of its corners. Figure 18.3 shows the confounding rectangle for the six age strata.

When there is no confounding of the causal effect of \(X\) on \(D\) by \(C\), the crude point will always be inside the standardized hull. Each point in the standardized hull is a marginal causal point for some standard population. For \(k > 2\), it is possible to get a crude point inside the standardized hull even when there is confounding, in which case the marginal causal point we calculate is not actually the marginal causal point for our standard population. In the limit of a large sample, there must be confounding if the crude point is outside the standardized hull.

Code
rothman-conf7.R
## Rothman diagram for smoking and 20-year mortality

# load R packages
library(dplyr)
library(plotrix)

# data from Appleton et al. (The American Statistician, 1996)
# Using an ordered factor allows the use of <, =, and > for comparison.
agegroups <- factor(c("18-24", "25-34", "35-44", "45-54", "55-64",
                      "65-74", "75+"),
                    ordered = TRUE)
AFVdat <- data.frame(smoking = rep(c(0, 0, 1, 1), times = length(agegroups)),
                     death = rep(c(0, 1, 0, 1), times = length(agegroups)),
                     age = rep(agegroups, each = 4))
AFVrows <- rep(seq_len(nrow(AFVdat)),
               times = c(61, 1, 53, 2, 152, 5, 121, 3, 114, 7, 95, 14, 66, 12,
                         103, 27, 81, 40, 64, 51, 28, 101, 7, 29, 0, 64, 0, 13))
AFVdat <- AFVdat[AFVrows, ]
AFVdat$binage <- case_when(AFVdat$age < "65-74" ~ "18-64",
                           AFVdat$age >= "65-74" ~ "65+")

# 2x2 tables
twobytwo <- function(covariate = NULL, dat = AFVdat) {
  # generate crude or stratified 2x2 tables
  # covariate should be a string naming a variable in dat
  formla <- "~ smoking + death"
  # update formula if there is a covariate specified
  if (!is.null(covariate)) formla <- paste(formla, "+", covariate)
  tab22 <- xtabs(formla, data = dat, drop.unused.levels = TRUE)
  # format stratified 2x2 tables into a list
  if (length(dim(tab22)) > 2) {
    tab22 <- unlist(apply(tab22, 3, list), recursive = FALSE)
  } else {
    tab22 <- list(tab22)
  }
  # reorder rows and columns and add margins to 2x2 table(s)
  lapply(tab22, function(x) addmargins(x[c(2, 1), ][, c(2, 1)]))
}
strat7 <- twobytwo("age")

# risk calculations
condrisk <- function(covariate = NULL, dat = AFVdat) {
  # function to calculate crude or stratified risks in smokers and nonsmokers
  # covariate should be a string naming a variable in dat
  strat2 <- twobytwo(covariate, dat)
  risk <- function(v) v[, 1] / v[, 3]   # v = (alive, dead)
  risks <- do.call(rbind, lapply(strat2, risk))
  colnames(risks) <- c("smokers", "nonsmokers", "marginal")
  as.data.frame(risks)
}
margrisk <- condrisk()
stratrisk7 <- condrisk("age")

# standardized risks of death over all age groups
age_n <- sapply(strat7, function(x) x[3, 3])
age_p <- age_n / sum(age_n)
stdrisk7_all <- data.frame(smokers = sum(stratrisk7$smokers * age_p),
                           nonsmokers = sum(stratrisk7$nonsmokers * age_p))
# smokers
age_nsmk <- sapply(strat7, function(x) x[1, 3])
age_psmk <- age_nsmk / sum(age_nsmk)
stdrisk7_smk <- data.frame(smokers = sum(stratrisk7$smokers * age_psmk),
                           nonsmokers = sum(stratrisk7$nonsmokers * age_psmk))
# nonsmokers
age_nnon <- sapply(strat7, function(x) x[2, 3])
age_pnon <- age_nnon / sum(age_nnon)
stdrisk7_non <- data.frame(smokers = sum(stratrisk7$smokers * age_pnon),
                           nonsmokers = sum(stratrisk7$nonsmokers * age_pnon))

# Rothman diagram with standarized hull and confounding rectangle
x7min <- min(stratrisk7$nonsmokers)
x7max <- max(stratrisk7$nonsmokers)
y7min <- min(stratrisk7$smokers)
y7max <- max(stratrisk7$smokers)
plot(stratrisk7$nonsmokers, stratrisk7$smokers, pch = 19,
     xlim = c(0, 1), ylim = c(0, 1), asp = 1,
     xlab = "Risk of death among the unexposed (nonsmokers)",
     ylab = "Risk of death among the exposed (smokers)")
segments(0, 0, 1, 1, col = "darkgray")
convhull <- chull(stratrisk7$nonsmokers, stratrisk7$smokers)
with(stratrisk7, polygon(nonsmokers[convhull], smokers[convhull],
                         lty = "solid"))
polygon(c(x7min, x7min, x7max, x7max), c(y7min, y7max, y7max, y7min),
        lty = "dashed")
points(margrisk$nonsmokers, margrisk$smokers)
points(stdrisk7_all$nonsmokers, stdrisk7_all$smokers)
points(stdrisk7_smk$nonsmokers, stdrisk7_smk$smokers)
points(stdrisk7_non$nonsmokers, stdrisk7_non$smokers)
grid()
text((x7min + x7max) / 2, y7max - 0.03,
     labels = "Confounding rectangle")
text(0.47, 0.51, srt = 45, label = "Standardized hull")
# labels for the 18-24 and 55-64 year age groups
toplabels <- c(1, 5)
text(stratrisk7$nonsmokers[toplabels] - 0.01,
     stratrisk7$smokers[toplabels] + 0.02,
     adj = c(1, 0), labels = rownames(stratrisk7)[toplabels])
# labels for the 25-34 and 75+ year age groups
bottomlabels <- c(2, 7)
text(stratrisk7$nonsmokers[bottomlabels] + 0.01,
     stratrisk7$smokers[bottomlabels] - 0.02,
     adj = c(0, 1), labels = rownames(stratrisk7)[bottomlabels])
# label for the 35-44 year age group
boxed.labels(stratrisk7$nonsmokers[3] - 0.05, stratrisk7$smokers[3] + 0.03,
          labels = rownames(stratrisk7)[3], xpad = 1, border = FALSE)
# label for the 45-54 year age group
boxed.labels(stratrisk7$nonsmokers[4] + 0.05, stratrisk7$smokers[4] - 0.03,
          labels = rownames(stratrisk7)[4], xpad = 1, border = FALSE)
# label for the 65-74 year age group
boxed.labels(stratrisk7$nonsmokers[6] + 0.06, stratrisk7$smokers[6] - 0.03,
          labels = rownames(stratrisk7)[6], xpad = 1, border = FALSE)
# crude point label
text(margrisk$nonsmokers + 0.01, margrisk$smokers - 0.02, adj = c(0, 1),
     labels = "Crude point")
# labels for standardized points
boxed.labels(stdrisk7_all$nonsmokers - 0.11, stdrisk7_all$smokers + 0.03,
          labels = "All participants", xpad = 1, border = FALSE)
boxed.labels(stdrisk7_smk$nonsmokers - 0.07, stdrisk7_smk$smokers + 0.03,
          labels = "Smokers", xpad = 1, border = FALSE)
boxed.labels(stdrisk7_non$nonsmokers - 0.09, stdrisk7_non$smokers + 0.03,
          labels = "Nonsmokers", xpad = 1, border = FALSE)
Figure 18.3: The standardized hull (solid) and the confounding rectangle (dashed) for six age strata adapted from Appleton, French, and Vanderpump (1996). Only the top right corner of the confounding rectangle is a stratum-specific point.

18.3 Effect measure modification

Effect measure modification occurs when a given stratum-specific measures of association differs across strata. Unlike confounding, effect measure modification depends on the scale or measure of association we use. The relationship between confounding and effect measure modification has often been a source of confusion and mythology in epidemiology, but there is really no relationship at all.

18.3.1 Contour lines

On a Rothman diagram, every point in the unit square represents a risk in the exposed and a risk in the unexposed. We can use these risks to calculate measures of association such as the odds ratio, risk ratio, or risk difference. If we think of the odds ratio as a function \[ \OR(x, y) = \frac{y / (1 - y)}{x / (1 - x)}, \] then the set of points with \(\OR(x, y) = m\) for any given \(m\) is called a contour line or contour of the odds ratio. Contours can be straight lines or curves, and each possible \(m\) corresponds to a different contour line.

We can also find contour lines for the risk ratio \(\RR(x, y) = y / x\), the risk difference \(\RD(x, y) = y - x\), and the hazard ratio. To estimate the hazard ratio from binary data, we need to assume that there is a constant hazard ratio for the exposed compared to the unexposed during the time interval over which risk is defined. If so, this hazard ratio is \[ \CHR(x, y) = \frac{\log(1 - y)}{\log(1 - x)}. \] The incidence rate ratio is a special case of the hazard ratio where we assume an exponential distribution of times to disease onset in each exposure group.

Figure 18.4 shows contour lines for the odds ratio, risk ratio, risk difference, and hazard ratio Richardson, Robins, and Wang (2017). The null line is a contour line for all measures of association, corresponding to \(\RD(x, y) = 0\) and \(\OR(x, y) = \RR(x, y) = \CHR(x, y) = 1\). On a Rothman diagram, \(C\) is an effect modifier for a measure of association \(M\) when the stratum-specific points are on different contour lines of \(M\). If we randomly choose two points in the unit square, it would be an astonishing coincidence if both were on the same contour line for a given measure of association. Thus, effect measure modification should be seen as normal, not pathological or unusual.

Code
rothman-contours.R
## Contour lines for measures of association

# load R packages
require(plotrix)    # for boxed.labels()

# odds ratio, cumulative hazard ratio, and inverses
odds <- function(p) p / (1 - p)
invodds <- function(odds) odds / (1 + odds)
chaz <- function(p) -log(1 - p)
invchaz <- function(chaz) 1 - exp(-chaz)

# contour lines plot functions
# risk differences
riskdiff_contours <- function() {
  plot(x, x, type = "l", main = "Risk difference contours",
       xlab = "", ylab = "Risk in the exposed")
  grid()
  boxed.labels(.5, .5, "0", xpad = 1.5, ypad = 1.5, border = FALSE)
  for (riskdiff in c(-0.5, -0.2, 0, 0.2, 0.5)) {
    y <- x + riskdiff
    yrange <- y >= 0 & y <= 1
    lines(x[yrange], y[yrange], lty = "dashed")
    boxed.labels(0.5 - riskdiff / 2, 0.5 + riskdiff / 2,
                 as.character(riskdiff),
                 xpad = 1.5, ypad = 1.5, border = FALSE)
  }
}
# risk ratios
riskratio_contours <- function() {
  plot(x, x, type = "l", main = "Risk ratio contours",
       xlab = "", ylab = "")
  grid()
  boxed.labels(.5, .5, "1", xpad = 1.5, ypad = 1.5, border = FALSE)
  for (riskratio in c(0.2, 0.5, 2, 5)) {
    y <- riskratio * x
    yrange <- y <= 1
    lines(x[yrange], y[yrange], lty = "dashed")
    boxed.labels(1 / (riskratio + 1), riskratio / (riskratio + 1),
                 as.character(riskratio),
                 xpad = 1.5, ypad = 1.5, border = FALSE)
  }
}
# odds ratios
oddsratio_contours <- function() {
  plot(x, x, type = "l", main = "Odds ratio contours",
       xlab = "Risk in the unexposed",
       ylab = "Risk in the exposed")
  grid()
  boxed.labels(.5, .5, "1", xpad = 1.5, ypad = 1.5, border = FALSE)
  for (oddsratio in c(0.2, 0.5, 2, 5)) {
    lines(x, invodds(oddsratio * odds(x)), lty = "dashed")
    boxed.labels((sqrt(oddsratio) - 1) / (oddsratio - 1),
                 (oddsratio - sqrt(oddsratio)) / (oddsratio - 1),
                 as.character(oddsratio),
                 xpad = 1.5, ypad = 1.5, border = FALSE)
  }
}
# cumulative hazard ratios
chazratio_contours <- function() {
  plot(x, x, type = "l", main = "Cumulative hazard ratio contours",
       xlab = "Risk in the unexposed", ylab = "")
  grid()
  boxed.labels(.5, .5, "1", xpad = 1.5, ypad = 1.5, border = FALSE)
  for (chazratio in c(0.2, 0.5, 2, 5)) {
    lines(c(x, 1), c(invchaz(chazratio * chaz(x)), 1), lty = "dashed")
    labelx <- uniroot(function(x) x - (1 - x)^chazratio, c(0, 1))$root
    labely <- 1 - labelx
    boxed.labels(labelx, labely, as.character(chazratio),
                 xpad = 1.5, ypad = 1.5, border = FALSE)
  }
}

# plot array
oldmar <- par("mar")
oldmgp <- par("mgp")
par(mfrow = c(2, 2), mar = 0.6 * (c(5, 5, 4, 1) + 0.1), mgp = c(2, 1, 0))
x <- seq(0.001, 0.999, by = 0.001)
riskdiff_contours()
riskratio_contours()
oddsratio_contours()
chazratio_contours()

# reset graphical parameters
par(mfrow = c(1, 1), mar = oldmar, mgp = oldmgp)
Figure 18.4: Contour lines for the odds ratio, risk ratio, risk difference, and hazard ratio. The null line is solid. All other contours lines are dashed. Each contour line is labeled with the corresponding value of the measure of association.

18.3.2 Interaction

In a regression model, an interaction term is used to allow a measure of association between exposure and disease to differ between groups defined by third covariate. If \(X\) is treatment and \(C\) is a stratification variable (possibly but not necessarily to control confounding and selection bias), then a GLM with an interaction term is \[ g\bigl(\Pr(D = 1 \given{} C = c, X = x, S = 1)\bigr) = \beta_0 + \beta_1 x + \beta_2 c + \beta_3 xc. \] The change in \(g(\Pr(D = 1 \given{} C = c, X = x, S = 1))\) associated with a one-unit change in \(X\) given a fixed value \(C = c\) is \[ g\bigl(\Pr(D = 1 \given{} C = c, X = x + 1, S = 1)\bigr) - g\bigl(\Pr(D = 1 \given{} C = c, X = x, S = 1)\bigr) = \beta_1 + \beta_3 c. \] Table 18.4 shows how the scale on which the interaction term estimates effect measure modification depends on the link function \(g()\).

Table 18.4: Link functions and effect measure modification (for the conditional association of \(X\) and \(D\) given \(C\))
Link function Function Measure (given \(C\)) X = 0 X = 1
Identity \(g(y) = y\) Risk difference \(\beta_1\) \(\beta_1 + \beta_3\)
Log \(g(y) = \ln y\) Risk ratio \(e^{\beta_1}\) \(e^{\beta_1 + \beta_3}\)
Logit \(g(y) = \ln\bigl(\odds(y)\bigr)\) Odds ratio \(e^{\beta_1}\) \(e^{\beta_1 + \beta_3}\)
Complementary log-log \(g(y) = \ln\bigr(-\ln(1 - y)\bigl)\) Cumulative hazard ratio \(e^{\beta_1}\) \(e^{\beta_1 + \beta_3}\)

Table 18.5 shows stratum-specific measures of association estimated using binomial GLMs that include an interaction between smoking and age group with likelihood-ratio p-values for the null hypothesis that the coefficient on the interaction term equals zero. It also shows the unstratified measure of association estimated using the same binomial GLMs without an interaction. According to the point estimates alone, there is effect measure modification on all four scales—with a harmful effect of smoking in the 18-64 year age group and a near-null effect of smoking in the 65+ year age group. However, there is little evidence of effect measure modification on the odds ratio or the risk difference scales. There is weak evidence of effect measure modification on the hazard ratio scale and strong evidence on the risk ratio scale.

Table 18.5: Stratum-specific measures of association for smoking and 20-year mortality with likelihood ratio p-values for the interaction term and unstratified estimates with likelihood ratio 95% confidence intervals.
Stratum-specific estimates Unstratified estimate
18-64 years 65+ years p-value Estimate 95% confidence interval
Risk difference 0.061 0.002 0.300 0.052 (0.013, 0.091)
Risk ratio 1.509 1.003 0.010 1.062 (0.952, 1.166)
Odds ratio 1.622 1.018 0.353 1.537 (1.119, 2.125)
Cumulative hazard ratio 1.563 1.008 0.085 1.316 (1.034, 1.676)
rothman-glm2.R
## Binomial GLM analysis of smoking and 20-year mortality with interactions

# load R packages
library(dplyr)      # for case_when()
library(lmtest)     # for lrtest()

# data from Appleton et al. (The American Statistician, 1996)
# Using an ordered factor allows the use of <, =, and > for comparison.
agegroups <- factor(c("18-24", "25-34", "35-44", "45-54", "55-64",
                      "65-74", "75+"),
                    ordered = TRUE)
AFVdat <- data.frame(smoking = rep(c(0, 0, 1, 1), times = length(agegroups)),
                     death = rep(c(0, 1, 0, 1), times = length(agegroups)),
                     age = rep(agegroups, each = 4))
AFVrows <- rep(seq_len(nrow(AFVdat)),
               times = c(61, 1, 53, 2, 152, 5, 121, 3, 114, 7, 95, 14, 66, 12,
                         103, 27, 81, 40, 64, 51, 28, 101, 7, 29, 0, 64, 0, 13))
AFVdat <- AFVdat[AFVrows, ]
AFVdat$binage <- case_when(AFVdat$age < "65-74" ~ "18-64",
                           AFVdat$age >= "65-74" ~ "65+")

# binomial GLMs with identity link for risk difference
# Model without interaction requires a starting point for numerical stability.
# We get a starting point from a linear regression model.
intx_idbinom <- glm(death ~ smoking * binage, data = AFVdat,
                    family = binomial(link = "identity"))
nointx_lm <- lm(death ~ smoking + binage, data = AFVdat)
nointx_idbinom <- glm(death ~ smoking + binage, data = AFVdat,
                      family = binomial(link = "identity"),
                      start = coef(nointx_lm))

# log-binomial regression for risk ratio
# Both models require a starting point due to numerical instability.
# We get these from Poisson GLMs with a log link.
intx_poisson <- glm(death ~ smoking * binage, data = AFVdat,
                    family = poisson())
intx_logbinom <- glm(death ~ smoking * binage, data = AFVdat,
                     family = binomial(link = "log"),
                     start = coef(intx_poisson))
nointx_poisson <- glm(death ~ smoking + binage, data = AFVdat,
                      family = poisson())
nointx_logbinom <- glm(death ~ smoking + binage, data = AFVdat,
                       family = binomial(link = "log"),
                       start = coef(nointx_poisson) - 0.1)

# logistic regression (binomial GLM with logit link) for odds ratio
intx_logistic <- glm(death ~ smoking * binage, data = AFVdat,
                     family = binomial(link = "logit"))
nointx_logistic <- glm(death ~ smoking + binage, data = AFVdat,
                       family = binomial(link = "logit"))

# binomial GLM with complementary log-log link for cumulative hazard ratio
intx_chrbinom <- glm(death ~ smoking * binage, data = AFVdat,
                     family = binomial(link = "cloglog"))
nointx_chrbinom <- glm(death ~ smoking + binage, data = AFVdat,
                       family = binomial(link = "cloglog"))

# function to collect estimates from binomial GLMs
intxest <- function(model, model0) {
  # model has interaction term, model0 has no interaction term
  meas <- cumsum(coef(model)[c("smoking", "smoking:binage65+")])
  pval <- lrtest(model, model0)[2, "Pr(>Chisq)"]
  meas0 <- coef(model0)["smoking"]
  ci0 <- confint(model0)["smoking", ]
  if (model$family$link %in% c("log", "logit", "cloglog")) {
    meas <- exp(meas)
    meas0 <- exp(meas0)
    ci0 <- exp(ci0)
  }
  c("18-64" = meas[1], "65+" = meas[2], "pval" = pval,
    "unstrat" = meas0, ci0[1], ci0[2])
}

# stratum-specific and combined measures of association
intx_meas <- mapply(intxest,
                    model = list(riskdiff = intx_idbinom,
                                 riskratio = intx_logbinom,
                                 oddsratio = intx_logistic,
                                 chazratio = intx_chrbinom),
                    model0 = list(nointx_idbinom,
                                  nointx_logbinom,
                                  nointx_logistic,
                                  nointx_chrbinom))
# exchange rows and columns of intx_meas and rename columns
intx_tbl <- t(intx_meas)
colnames(intx_tbl)[1:4] <- c("18-64", "65+", "pval", "common")

The Rothman diagrams in Figure 18.5 show the contour lines for the stratum-specific measures of association and for the common measure of association on the odds ratio, risk ratio, risk difference, and hazard ratio scales. For each measure of association, the points for the 18-64 year age group and the 65+ year age group are on different contour lines, so there is effect measure modification by age group. On the odds ratio and risk difference scales, the contour line for the common estimate passes close to both stratum-specific points. On the risk ratio and hazard ratio scales, the stratum-specific points are farther from the contour line for the common estimate, which partly explains the lower p-values for the interaction term on these scales.

Code
rothman-intx.R
## Contour lines and interaction

# load R packages
library(dplyr)      # for case_when()
library(lmtest)     # for lrtest()

# odds ratio, cumulative hazard ratio, and inverses
odds <- function(p) p / (1 - p)
invodds <- function(odds) odds / (1 + odds)
chaz <- function(p) -log(1 - p)
invchaz <- function(chaz) 1 - exp(-chaz)

# data from Appleton et al. (The American Statistician, 1996)
# Using an ordered factor allows the use of <, =, and > for comparison.
agegroups <- factor(c("18-24", "25-34", "35-44", "45-54", "55-64",
                      "65-74", "75+"),
                    ordered = TRUE)
AFVdat <- data.frame(smoking = rep(c(0, 0, 1, 1), times = length(agegroups)),
                     death = rep(c(0, 1, 0, 1), times = length(agegroups)),
                     age = rep(agegroups, each = 4))
AFVrows <- rep(seq_len(nrow(AFVdat)),
               times = c(61, 1, 53, 2, 152, 5, 121, 3, 114, 7, 95, 14, 66, 12,
                         103, 27, 81, 40, 64, 51, 28, 101, 7, 29, 0, 64, 0, 13))
AFVdat <- AFVdat[AFVrows, ]
AFVdat$binage <- case_when(AFVdat$age < "65-74" ~ "18-64",
                           AFVdat$age >= "65-74" ~ "65+")

# 2x2 tables
twobytwo <- function(covariate = NULL, dat = AFVdat) {
  # generate crude or stratified 2x2 tables
  # covariate should be a string naming a variable in dat
  formla <- "~ smoking + death"
  # update formula if there is a covariate specified
  if (!is.null(covariate)) formla <- paste(formla, "+", covariate)
  tab22 <- xtabs(formla, data = dat, drop.unused.levels = TRUE)
  # format stratified 2x2 tables into a list
  if (length(dim(tab22)) > 2) {
    tab22 <- unlist(apply(tab22, 3, list), recursive = FALSE)
  } else {
    tab22 <- list(tab22)
  }
  # reorder rows and columns and add margins to 2x2 table(s)
  lapply(tab22, function(x) addmargins(x[c(2, 1), ][, c(2, 1)]))
}

# risk calculations
condrisk <- function(covariate = NULL, dat = AFVdat) {
  # function to calculate crude or stratified risks in smokers and nonsmokers
  # covariate should be a string naming a variable in dat
  strat2 <- twobytwo(covariate, dat)
  risk <- function(v) v[, 1] / v[, 3]   # v = (alive, dead)
  risks <- do.call(rbind, lapply(strat2, risk))
  colnames(risks) <- c("smokers", "nonsmokers", "marginal")
  as.data.frame(risks)
}
margrisk <- condrisk()
stratrisk <- condrisk("binage")

# binomial GLMs with identity link for risk difference
# Model without interaction requires a starting point for numerical stability.
# We get a starting point from a linear regression model.
intx_idbinom <- glm(death ~ smoking * binage, data = AFVdat,
                    family = binomial(link = "identity"))
nointx_lm <- lm(death ~ smoking + binage, data = AFVdat)
nointx_idbinom <- glm(death ~ smoking + binage, data = AFVdat,
                      family = binomial(link = "identity"),
                      start = coef(nointx_lm))

# log-binomial regression for risk ratio
# Both models require a starting point due to numerical instability.
# We get these from Poisson GLMs with a log link.
intx_poisson <- glm(death ~ smoking * binage, data = AFVdat,
                    family = poisson())
intx_logbinom <- glm(death ~ smoking * binage, data = AFVdat,
                     family = binomial(link = "log"),
                     start = coef(intx_poisson))
nointx_poisson <- glm(death ~ smoking + binage, data = AFVdat,
                      family = poisson())
nointx_logbinom <- glm(death ~ smoking + binage, data = AFVdat,
                       family = binomial(link = "log"),
                       start = coef(nointx_poisson) - 0.1)

# logistic regression (binomial GLM with logit link) for odds ratio
intx_logistic <- glm(death ~ smoking * binage, data = AFVdat,
                     family = binomial(link = "logit"))
nointx_logistic <- glm(death ~ smoking + binage, data = AFVdat,
                       family = binomial(link = "logit"))

# binomial GLM with complementary log-log link for cumulative hazard ratio
intx_chrbinom <- glm(death ~ smoking * binage, data = AFVdat,
                     family = binomial(link = "cloglog"))
nointx_chrbinom <- glm(death ~ smoking + binage, data = AFVdat,
                       family = binomial(link = "cloglog"))

# function to collect estimates from binomial GLMs
intxest_plot <- function(model, model0) {
  # model has interaction term, model0 has no interaction term
  meas <- cumsum(coef(model)[c("smoking", "smoking:binage65+")])
  meas0 <- coef(model0)["smoking"]
  ci0 <- confint(model0)["smoking", ]
  if (model$family$link %in% c("log", "logit", "cloglog")) {
    meas <- exp(meas)
    meas0 <- exp(meas0)
    ci0 <- exp(ci0)
  }
  c("18-64" = meas[1], "65+" = meas[2], "common" = meas0)
}

# stratum-specific and combined measures of association
intx_meas <- mapply(intxest_plot,
                    model = list(riskdiff = intx_idbinom,
                                 riskratio = intx_logbinom,
                                 oddsratio = intx_logistic,
                                 chazratio = intx_chrbinom),
                    model0 = list(nointx_idbinom,
                                  nointx_logbinom,
                                  nointx_logistic,
                                  nointx_chrbinom))
# exchange rows and columns of intx_meas and rename columns
intx_tbl <- t(intx_meas)
colnames(intx_tbl) <- c("18-64", "65+", "common")

# Rothman diagrams with estimated effect measure modification
# risk difference interaction
riskdiff_intx <- function() {
  plot(stratrisk$nonsmokers, stratrisk$smokers, pch = 19,
       xlim = c(0, 1), ylim = c(0, 1),
       main = "Risk difference estimates",
       xlab = "", ylab = "Risk in the exposed (smokers)")
  y <- intx_tbl["riskdiff", "common"] + x
  yrange <- y >= 0 & y <= 1
  lines(x[yrange], y[yrange])
  y0 <- intx_tbl["riskdiff", "18-64"] + x
  y0range <- y0 >= 0 & y0 <= 1
  lines(x[y0range], y0[y0range], lty = "dashed")
  y1 <- intx_tbl["riskdiff", "65+"] + x
  y1range <- y1 >= 0 & y1 <= 1
  lines(x[y1range], y1[y1range], lty = "dashed")
  grid()
  text(stratrisk$nonsmokers[1] - 0.02, stratrisk$smokers[1] + 0.02,
       adj = c(1, 0), labels = rownames(stratrisk)[1])
  text(stratrisk$nonsmokers[2] + 0.02, stratrisk$smokers[2] - 0.02,
       adj = c(0, 1), labels = rownames(stratrisk)[2])
}
# risk ratio interaction
riskratio_intx <- function() {
  plot(stratrisk$nonsmokers, stratrisk$smokers, pch = 19,
       xlim = c(0, 1), ylim = c(0, 1),
       main = "Risk ratio estimates", xlab = "", ylab = "")
  y <- intx_tbl["riskratio", "common"] * x
  yrange <- y >= 0 & y <= 1
  lines(x[yrange], y[yrange])
  y0 <- intx_tbl["riskratio", "18-64"] * x
  y0range <- y0 >= 0 & y0 <= 1
  lines(x[y0range], y0[y0range], lty = "dashed")
  y1 <- intx_tbl["riskratio", "65+"] * x
  y1range <- y1 >= 0 & y1 <= 1
  lines(x[y1range], y1[y1range], lty = "dashed")
  grid()
  text(stratrisk$nonsmokers[1] - 0.02, stratrisk$smokers[1] + 0.02,
       adj = c(1, 0), labels = rownames(stratrisk)[1])
  text(stratrisk$nonsmokers[2] + 0.02, stratrisk$smokers[2] - 0.02,
       adj = c(0, 1), labels = rownames(stratrisk)[2])
}
# odds ratio interaction
oddsratio_intx <- function() {
  plot(stratrisk$nonsmokers, stratrisk$smokers, pch = 19,
       xlim = c(0, 1), ylim = c(0, 1),
       main = "Odds ratio estimates",
       xlab = "Risk in the unexposed (nonsmokers)",
       ylab = "Risk in the exposed (smokers)")
  grid()
  text(stratrisk$nonsmokers[1] - 0.02, stratrisk$smokers[1] + 0.02,
       adj = c(1, 0), labels = rownames(stratrisk)[1])
  text(stratrisk$nonsmokers[2] + 0.02, stratrisk$smokers[2] - 0.02,
       adj = c(0, 1), labels = rownames(stratrisk)[2])
  lines(x, invodds(intx_tbl["oddsratio", "common"] * odds(x)))
  lines(x, invodds(intx_tbl["oddsratio", "18-64"] * odds(x)), lty = "dashed")
  lines(x, invodds(intx_tbl["oddsratio", "65+"] * odds(x)), lty = "dashed")
}
# cumulative hazard ratio interaction
chazratio_intx <- function() {
  plot(stratrisk$nonsmokers, stratrisk$smokers, pch = 19,
       xlim = c(0, 1), ylim = c(0, 1),
       main = "Cumulative hazard ratio estimates",
       xlab = "Risk in the unexposed (nonsmokers)", ylab = "")
  lines(x, invchaz(intx_tbl["chazratio", "common"] * chaz(x)))
  lines(x, invchaz(intx_tbl["chazratio", "18-64"] * chaz(x)), lty = "dashed")
  lines(x, invchaz(intx_tbl["chazratio", "65+"] * chaz(x)), lty = "dashed")
  # lines(x, 1 - (1 - x)^intx_tbl["chazratio", "common"])
  # lines(x, 1 - (1 - x)^intx_tbl["chazratio", "18-64"], lty = "dashed")
  # lines(x, 1 - (1 - x)^intx_tbl["chazratio", "65+"], lty = "dashed")
  grid()
  text(stratrisk$nonsmokers[1] - 0.02, stratrisk$smokers[1] + 0.02,
       adj = c(1, 0), labels = rownames(stratrisk)[1])
  text(stratrisk$nonsmokers[2] + 0.02, stratrisk$smokers[2] - 0.02,
       adj = c(0, 1), labels = rownames(stratrisk)[2])
}

# plot array
oldmar <- par("mar")
oldmgp <- par("mgp")
par(mfrow = c(2, 2), mar = 0.6 * (c(5, 5, 4, 1) + 0.1), mgp = c(2, 1, 0))
x <- seq(0.001, 0.999, by = 0.001)
riskdiff_intx()
riskratio_intx()
oddsratio_intx()
chazratio_intx()

# reset graphical parameters
par(mfrow = c(1, 1), mar = oldmar, mgp = oldmgp)


# ## Collapsibility
# pred_newdata <- data.frame(binage = rep(c("18-64", "65+"), each = 2),
#                            smoking = rep(c(0, 1), times = 2))
# predformat <- function(predrisk) {
#   data.frame(matrix(predrisk, ncol = 2, byrow = TRUE,
#                     dimnames = list(c("18-64", "65+"),
#                                     c("nonsmokers", "smokers"))))
# }
# predrisk_logistic <- predformat(predict(nointx_logistic, type = "response",
#                                         newdata = pred_newdata))
# predrisk_idbinom <- predformat(predict(nointx_idbinom, type = "response",
#                                        newdata = pred_newdata))
# # find minimum odds ratio
# std_odds <- function(t) {
#   xcoord <- with(predrisk_logistic,
#                  (1 - t) * nonsmokers[1] + t * nonsmokers[2])
#   ycoord <- with(predrisk_logistic, (1 - t) * smokers[1] + t * smokers[2])
#   odds(ycoord) / odds(xcoord)
# }
# minodds <- optimize(std_odds, c(0, 1))
# tmin <- minodds$minimum
# xmin <- with(predrisk_logistic,
#              (1 - tmin) * nonsmokers[1] + tmin * nonsmokers[2])
# ymin <- with(predrisk_logistic, (1 - tmin) * smokers[1] + tmin * smokers[2])
# cat("\n", "Minimum standardized odds ratio is ",
#     minodds$objective, ".\n", sep = "")
# cat("It occurs in a standard population where Pr(65+) =", tmin, "\n")
# cat("and Pr(18-64) = ", 1 - tmin, ".\n\n", sep = "")

# # risk difference collapsibility plot (Figure 6)
# dev.new()
# plot(predrisk_idbinom$nonsmokers, predrisk_idbinom$smokers, pch = 19,
#      xlim = c(0, 1), ylim = c(0, 1), asp = 1,
#      xlab = "Risk in the unexposed (nonsmokers)",
#      ylab = "Risk in the exposed (smokers)")
# y <- x + intx_meas["riskdiff", "common"]
# yrange <- y >= 0 & y <= 1
# lines(x[yrange], y[yrange], lty = "dashed")
# segments(0, 0, 1, 1, col = "darkgray")
# segments(predrisk_idbinom["18-64", "nonsmokers"],
#          predrisk_idbinom["18-64", "smokers"],
#          predrisk_idbinom["65+", "nonsmokers"],
#          predrisk_idbinom["65+", "smokers"])
# grid()
# text(0.1, 0.06, srt = 45, col = "darkgray", labels = "Null line")
# text(0.46, 0.56, srt = 45, labels = "Common and standardized RD = 0.052")
# # dev.copy2pdf(file = "collapsibilityRD.pdf")

# # odds ratio noncollapsibility plot (Figure 7)
# dev.new()
# plot(predrisk_logistic$nonsmokers, predrisk_logistic$smokers, pch = 19,
#      xlim = c(0, 1), ylim = c(0, 1), asp = 1,
#      xlab = "Risk in the unexposed (nonsmokers)",
#      ylab = "Risk in the exposed (smokers)")
# lines(x, invodds(intx_meas["oddsratio", "common"] * odds(x)), lty = "dashed")
# segments(0, 0, 1, 1, col = "darkgray")
# segments(predrisk_logistic["18-64", "nonsmokers"],
#          predrisk_logistic["18-64", "smokers"],
#          predrisk_logistic["65+", "nonsmokers"],
#          predrisk_logistic["65+", "smokers"])
# points(xmin, ymin)
# grid()
# text(0.1, 0.06, srt = 45, col = "darkgray", labels = "Null line")
# text(0.44, 0.58, srt = 42, labels = "Common OR = 1.537")
# text(predrisk_logistic$nonsmokers - 0.02,
#      predrisk_logistic$smokers + 0.02,
#      adj = c(1, 0), labels = rownames(predrisk_logistic))
# boxed.labels(xmin + 0.21, ymin - 0.02, labels = "Standardized OR = 1.229",
#              xpad = 1, ypad = 1.5, border = FALSE)
# text(xmin + 0.02, ymin - 0.04, adj = c(0, 1),
#      labels = expression("when Pr"["std"]("18-64") == 0.484))
# # dev.copy2pdf(file = "collapsibilityOR.pdf")
Figure 18.5: Contour lines containing the stratum-specific points (dashed) and the contour line corresponding to the common measure of association (solid) for the risk difference, risk ratio, odds ratio, and cumulative hazard ratio.

We can evaluate effect measure modification whether or not the “effects” are causal. There is effect modification on a given scale when the stratum-specific measures of association are on different contour lines for the measure of association, which can occur whether or not the crude point is on the standardized segment. There is confounding when the crude point is off the standardized segment (or outside the standardized hull), which can occur whether or not the stratum-specific points are on different contour lines for a given measure of association. Confounding and effect modification are logically independent. However, we must control confounding if we want to determine whether a causal effect differs between strata.

18.4 Collapsibility

If \(C\) is a risk factor for disease but not a confounder, a measure of association \(M\) is said to be collapsible if \(M = m\) in the marginal 2x2 table whenever \(M = m\) in all 2x2 tables defined by strata \(C\) (Whittemore 1978; Greenland, Pearl, and Robins 1999). Thus, the marginal and stratum-specific values of a collapsible measure \(M\) are equal whenever there is no confounding by \(C\) and no effect modification of \(M\) by \(C\). A measure that is not collapsible is noncollapsible. The risk ratio and risk difference are collapsible but the odds ratio and cumulative hazard ratio are not (Samuels 1981; Miettinen and Cook 1981; Greenland 1996).

18.4.1 Definition in terms of standardized measures

An equivalent but simpler definition is that \(M\) is collapsible if the standardized \(M = m\) whenever \(M = m\) in each stratum of \(C\). Because standardization removes any confounding by \(C\), this is equivalent to the definition that assumes no confounding by \(C\).

Leaving confounding out of the definition of collapsibility avoids a common source of confusion in epidemiology and biostatistics, where students are often taught to detect confounding by looking for a change in an estimated measure of association upon adjustment for a covariate. This change-in-estimates method can spuriously detect confounding when it is based on a noncollapsible measure of association (Miettinen and Cook 1981; Greenland, Pearl, and Robins 1999).

18.4.2 Straight contour lines

A measure \(M\) is collapsible if and only if all of its contour lines are straight. In Figure 18.4, the collapsible risk ratio and risk difference have straight contours but the noncollapsible odds ratio and hazard ratio have curved contours. Because the null line is a contour for all measures of association and it is straight, all measures of association are collapsible under the null hypothesis.

If all contours of \(M\) are straight and there is no effect measure modification of \(M\) by \(C\), then all stratum-specific points for \(M\) given \(C\) lie on the contour of \(M\) corresponding to the common \(M = m\). Because the stratum-specific points given \(C\) are all contained in a line segment, this is also the standardized segment (or standardized hull if \(C\) has more than two levels). Any standardized point must be on the same contour of \(M\), so the standardized \(M = m\) for any standard population. Therefore, \(M\) is collapsible if all of its contour lines are straight. This situation is illustrated in Figure 18.6, where all standardized risk differences equal the common stratum-specific risk difference of \(0.052\).

Code
rothman-collaps.R
## Collapsibility and straight contour lines (risk difference)

# load R packages
library(dplyr)      # for case_when()

# data from Appleton et al. (The American Statistician, 1996)
# Using an ordered factor allows the use of <, =, and > for comparison.
agegroups <- factor(c("18-24", "25-34", "35-44", "45-54", "55-64",
                      "65-74", "75+"),
                    ordered = TRUE)
AFVdat <- data.frame(smoking = rep(c(0, 0, 1, 1), times = length(agegroups)),
                     death = rep(c(0, 1, 0, 1), times = length(agegroups)),
                     age = rep(agegroups, each = 4))
AFVrows <- rep(seq_len(nrow(AFVdat)),
               times = c(61, 1, 53, 2, 152, 5, 121, 3, 114, 7, 95, 14, 66, 12,
                         103, 27, 81, 40, 64, 51, 28, 101, 7, 29, 0, 64, 0, 13))
AFVdat <- AFVdat[AFVrows, ]
AFVdat$binage <- case_when(AFVdat$age < "65-74" ~ "18-64",
                           AFVdat$age >= "65-74" ~ "65+")

# binomial GLM with identity link for risk difference
# Model without interaction requires a starting point for numerical stability.
# We get a starting point from a linear regression model.
nointx_lm <- lm(death ~ smoking + binage, data = AFVdat)
nointx_idbinom <- glm(death ~ smoking + binage, data = AFVdat,
                      family = binomial(link = "identity"),
                      start = coef(nointx_lm))

# risk difference collapsibility plot
pred_newdata <- data.frame(binage = rep(c("18-64", "65+"), each = 2),
                           smoking = rep(c(0, 1), times = 2))
predformat <- function(predrisk) {
  data.frame(matrix(predrisk, ncol = 2, byrow = TRUE,
                    dimnames = list(c("18-64", "65+"),
                                    c("nonsmokers", "smokers"))))
}
predrisk_idbinom <- predformat(predict(nointx_idbinom, type = "response",
                                       newdata = pred_newdata))
plot(predrisk_idbinom$nonsmokers, predrisk_idbinom$smokers, pch = 19,
     xlim = c(0, 1), ylim = c(0, 1), asp = 1,
     xlab = "Risk in the unexposed (nonsmokers)",
     ylab = "Risk in the exposed (smokers)")
x <- seq(0, 1, by = 0.01)
y <- x + coef(nointx_idbinom)["smoking"]
yrange <- y >= 0 & y <= 1
lines(x[yrange], y[yrange], lty = "dashed")
segments(0, 0, 1, 1, col = "darkgray")
segments(predrisk_idbinom["18-64", "nonsmokers"],
         predrisk_idbinom["18-64", "smokers"],
         predrisk_idbinom["65+", "nonsmokers"],
         predrisk_idbinom["65+", "smokers"])
grid()
text(0.1, 0.06, srt = 45, col = "darkgray", labels = "Null line")
text(0.45, 0.57, srt = 45, labels = "Common and standardized RD = 0.052")
Figure 18.6: Collapsibility along a straight contour line. The entire standardized segment is contained on the common risk difference contour. The estimated risks are based on a binomial GLM with an identity link and no interaction.

Suppose \(M\) has curved contour lines but there is no effect measure modification of \(M\) by \(C\). Then all stratum-specific points for \(M\) lie on the same curved contour corresponding to the common measure \(M = m\). If we pick any two stratum-specific points and connect them with a straight line segment, then this segment is not contained in the same contour of \(M\). Thus, we can find a standard population where the standardized \(M \neq m\). Therefore, \(M\) is collapsible only if its contour lines are straight. This situation is illustrated in Figure 18.7, where the stratum-specific odds ratio is \(1.537\) but the standardized segment has a minimum odds ratio of \(1.229\), which occurs in a standard population that is approximately \(48.4\%\) aged 18-64 years and \(51.6\%\) aged \(\geq 65\) years.

Code
rothman-noncollaps.R
## Noncollapsibility and curved contour lines (odds ratio)

# load R packages
library(dplyr)      # for case_when()
library(plotrix)    # for boxed.labels()

# odds ratio and inverse
odds <- function(p) p / (1 - p)
invodds <- function(odds) odds / (1 + odds)

# data from Appleton et al. (The American Statistician, 1996)
# Using an ordered factor allows the use of <, =, and > for comparison.
agegroups <- factor(c("18-24", "25-34", "35-44", "45-54", "55-64",
                      "65-74", "75+"),
                    ordered = TRUE)
AFVdat <- data.frame(smoking = rep(c(0, 0, 1, 1), times = length(agegroups)),
                     death = rep(c(0, 1, 0, 1), times = length(agegroups)),
                     age = rep(agegroups, each = 4))
AFVrows <- rep(seq_len(nrow(AFVdat)),
               times = c(61, 1, 53, 2, 152, 5, 121, 3, 114, 7, 95, 14, 66, 12,
                         103, 27, 81, 40, 64, 51, 28, 101, 7, 29, 0, 64, 0, 13))
AFVdat <- AFVdat[AFVrows, ]
AFVdat$binage <- case_when(AFVdat$age < "65-74" ~ "18-64",
                           AFVdat$age >= "65-74" ~ "65+")

# logistic regression (binomial GLM with logit link) for odds ratio
nointx_logistic <- glm(death ~ smoking + binage, data = AFVdat,
                       family = binomial(link = "logit"))

# noncollapsibility of the odds ratio
pred_newdata <- data.frame(binage = rep(c("18-64", "65+"), each = 2),
                           smoking = rep(c(0, 1), times = 2))
predformat <- function(predrisk) {
  data.frame(matrix(predrisk, ncol = 2, byrow = TRUE,
                    dimnames = list(c("18-64", "65+"),
                                    c("nonsmokers", "smokers"))))
}
predrisk_logistic <- predformat(predict(nointx_logistic, type = "response",
                                        newdata = pred_newdata))
# find minimum odds ratio
std_odds <- function(t) {
  xcoord <- with(predrisk_logistic,
                 (1 - t) * nonsmokers[1] + t * nonsmokers[2])
  ycoord <- with(predrisk_logistic, (1 - t) * smokers[1] + t * smokers[2])
  odds(ycoord) / odds(xcoord)
}
minodds <- optimize(std_odds, c(0, 1))
tmin <- minodds$minimum
xmin <- with(predrisk_logistic,
             (1 - tmin) * nonsmokers[1] + tmin * nonsmokers[2])
ymin <- with(predrisk_logistic, (1 - tmin) * smokers[1] + tmin * smokers[2])

# odds ratio noncollapsibility plot
plot(predrisk_logistic$nonsmokers, predrisk_logistic$smokers, pch = 19,
     xlim = c(0, 1), ylim = c(0, 1), asp = 1,
     xlab = "Risk in the unexposed (nonsmokers)",
     ylab = "Risk in the exposed (smokers)")
x <- seq(0.01, 0.99, by = 0.01)
common_OR <- exp(coef(nointx_logistic)["smoking"])
lines(x, invodds(common_OR * odds(x)), lty = "dashed")
segments(0, 0, 1, 1, col = "darkgray")
segments(predrisk_logistic["18-64", "nonsmokers"],
         predrisk_logistic["18-64", "smokers"],
         predrisk_logistic["65+", "nonsmokers"],
         predrisk_logistic["65+", "smokers"])
points(xmin, ymin)
grid()
text(0.1, 0.06, srt = 45, col = "darkgray", labels = "Null line")
text(0.43, 0.59, srt = 44, labels = "Common OR = 1.537")
text(predrisk_logistic$nonsmokers - 0.02,
     predrisk_logistic$smokers + 0.02,
     adj = c(1, 0), labels = rownames(predrisk_logistic))
boxed.labels(xmin + 0.21, ymin - 0.02, labels = "Standardized OR = 1.229",
             xpad = 1, ypad = 1.5, border = FALSE)
text(xmin + 0.02, ymin - 0.04, adj = c(0, 1),
     labels = expression("when Pr"["std"]("18-64") == 0.484))
Figure 18.7: Noncollapsibility along a curved contour line. Except for its endpoints at the stratum-specific points, the entire standardized segment is between the null line and the contour for the common odds ratio. The estimated risks are based on a logistic regression model with no interaction.

18.4.3 Noncollapsibility and changes upon adjustment

A change in an estimated measure of association upon covariate adjustment is caused by a combination of confounding, selection bias, effect measure modification, and noncollapsibility. Generating a large difference between adjusted and unadjusted measures through noncollapsibility alone requires a common stratum-specific estimate far from the null (so the contour has high curvature) and large differences in risk between strata. For the odds ratio and cumulative hazard ratio, noncollapsibility generates bias toward the null but never across the null. Thus, the changes caused by noncollapsibility alone have a predictable direction and are usually small.

Confounding, selection bias, and effect measure modification can generate large changes much more easily than noncollapsibility, and these changes can occur in any direction—including across the null. These sources of bias affect all measures of association, whether collapsible or not.

Noncollapsibility reflects a genuine difference between marginal and conditional measures of association, not bias. Collapsible measures such as the risk difference or risk ratio allow us to ignore this difference under ideal conditions with no confounding, no selection bias, and no effect measure modification by \(C\). Noncollapsibility is not a reason to avoid using measures of association such as the odds ratio or cumulative hazard ratio.