Why Work Through a Numerical Example?
In a two-visit study, treatment at the first visit can change a covariate measured later. That covariate may then influence both second-visit treatment and the outcome. The resulting feedback makes it easy for an ordinary regression coefficient to answer a different question from the one a researcher intends. A numerical example makes the distinction concrete: we can calculate the causal effect of specified treatment regimes and compare it directly with regression contrasts from the same data-generating process.
Let \(A_1\) denote first-visit treatment, \(L_2\) disease severity measured before the second-visit treatment, \(A_2\) second-visit treatment, and \(Y\) the outcome. For simplicity, treatment and severity are binary, with 1 indicating treatment or high severity. The ordering is \(A_1\), then \(L_2\), then \(A_2\), then \(Y\). The example has no baseline covariates.
The example below is deliberately simple, but it has the essential structure. Its assignment probabilities are strictly between zero and one, so both levels of each treatment can occur in the relevant histories. We assume consistency: a person’s observed outcome under their observed treatment history is the outcome corresponding to that history. We also specify the conditional outcome model and assignment process completely, so calculations do not require an unmeasured-confounding assumption beyond the model as stated.
The Data-Generating Process
Suppose \(A_1\) is randomized with probability one-half. First-visit treatment reduces the probability of high severity at the next visit. Given severity, second-visit treatment is more likely for patients with high severity:
The outcome model says that, holding the other variables fixed, either treatment lowers the outcome by 2 units and high severity raises it by 5 units. The outcome is deterministic given \(A_1,L_2,A_2\); allowing independent mean-zero noise would not change the regression coefficients calculated below. The causal structure is \(A_1\to L_2\to A_2\to Y\), with additional arrows \(L_2\to Y\), \(A_1\to Y\), and \(A_1\to L_2\).
Worked Example: Calculating Outcomes Under Treatment Regimes
A treatment regime in this example fixes both treatment decisions: \(A_1=a_1\) and \(A_2=a_2\). Severity is not fixed; it follows its specified distribution under the chosen first-visit treatment. Calculate the mean outcome under each regime.
Under \(A_1=a_1\), the probability of high severity is \(0.8\) when \(a_1=0\) and \(0.2\) when \(a_1=1\). In either case, \(E[L_2\mid do(A_1=a_1)]=0.8-0.6a_1\). Therefore,
The four regime means are \(14\) for \((a_1,a_2)=(0,0)\), \(12\) for \((0,1)\), \(9\) for \((1,0)\), and \(7\) for \((1,1)\). For example, changing the first-visit treatment from 0 to 1 while holding the second-visit treatment fixed changes the regime mean by \(9-14=-5\) when \(a_2=0\), and by \(7-12=-5\) when \(a_2=1\). This total effect includes the pathway through the reduction in severity. Changing second-visit treatment from 0 to 1 changes the regime mean by \(-2\), for either value of \(a_1\).
Why the Regression Contrast for Later Treatment Misleads
Now consider the ordinary linear regression of \(Y\) on \(A_1\) and \(A_2\), omitting \(L_2\). The coefficient of \(A_2\) compares outcomes associated with second-visit treatment among people with the same \(A_1\), but it does not hold severity fixed. Since severity makes second-visit treatment more likely and raises the outcome, the treated group at visit 2 is enriched for high-severity patients.
To derive the regression coefficient, first consider the linear projection of \(L_2\) on an intercept, \(A_1\), and \(A_2\). Because \(A_1\) is binary, the coefficient of \(A_2\) in this projection is the common within-\(A_1\)-stratum slope, if the stratum slopes agree. In the \(A_1=0\) stratum,
and \(\operatorname{Var}(A_2\mid A_1=0)=0.68(0.32)=0.2176\). Thus the within-stratum slope is \(0.096/0.2176=15/34\). In the \(A_1=1\) stratum,
and \(\operatorname{Var}(A_2\mid A_1=1)=0.32(0.68)=0.2176\), giving the same slope, \(15/34\). Because the outcome is \(Y=10-2A_1-2A_2+5L_2\), its projection on \(A_1,A_2\) has \(A_2\) coefficient \(-2+5(15/34)=7/34\). The omitted severity contribution has changed the sign: the regression suggests a positive contrast, while the causal effect is negative.
This derivation is exact for the population regression. It requires finite second moments and a nonsingular predictor covariance matrix, both of which hold here: the treatment probabilities are strictly between zero and one in each severity history, and all combinations needed for the regression occur with positive probability. In a sample, an estimated coefficient will vary around its population counterpart.
Worked Example: Checking the Regression Coefficient
Verify the result by considering the linear projection of \(Y\) on \(A_1,A_2\). The conditional outcome equation contains a term \(5L_2\), so the part of \(L_2\) linearly predicted by \(A_2\), after accounting for \(A_1\), contributes \(5\) times its projection slope to the \(A_2\) coefficient.
The two stratum calculations give a severity projection slope of \(15/34\). Therefore, the regression coefficient is
The sign is positive because the omitted-severity component, \(75/34\), exceeds the true treatment contribution, \(-68/34\). This is not a claim that regression is intrinsically inappropriate; it is a diagnosis of what this particular regression does when it omits a variable that confounds the later treatment-outcome relationship.
Crude Association and Covariate Adjustment
Worked Example: Comparing the Crude Association With the Regime Effect
Calculate the difference in observed mean outcomes between people who did and did not receive \(A_2=1\), without adjusting for \(A_1\) or \(L_2\). First, \(P(A_2=1)=0.5\): the marginal probability of high severity is \(0.5\), and so \(P(A_2=1)=0.5(0.8)+0.5(0.2)=0.5\).
The joint probabilities give \(P(A_1=1\mid A_2=1)=0.16/0.5=0.32\) and \(P(A_1=1\mid A_2=0)=0.34/0.5=0.68\). Similarly, \(P(L_2=1\mid A_2=1)=0.4/0.5=0.8\), whereas \(P(L_2=1\mid A_2=0)=0.1/0.5=0.2\). Hence,
The crude difference is \(11.36-9.64=1.72\), again positive, whereas setting \(A_2\) to 1 rather than 0 lowers the mean outcome by 2 under either regime for \(A_1\). This crude difference also reflects the different distributions of first-visit treatment and severity in the two observed treatment groups.
A regression that adjusts for \(L_2\) as well as \(A_1\) reproduces the specified conditional outcome equation in this example, so its \(A_2\) coefficient is \(-2\). But coefficients from different adjustment sets need not target the same causal quantity. In particular, holding \(L_2\) fixed when comparing \(A_1\) removes the part of the first-visit treatment effect carried through severity. The regime calculation above instead lets severity follow its distribution under each first-visit treatment. Choosing an adjustment set therefore requires deciding which contrast is wanted, not simply adding every measured covariate to a regression.
Reading the Example as a Diagnostic
The calculations show three distinct comparisons: the crude observed difference for \(A_2\) is \(1.72\), the coefficient of \(A_2\) after adjusting for \(A_1\) but omitting \(L_2\) is \(7/34\), and the specified causal contrast for \(A_2\) is \(-2\). Each is a well-defined quantity, but only the last is the intervention contrast in the stated model. The first two remain associated with severity because the model makes severity predictive of both later treatment and outcome.
In an applied analysis, warning signs include a strong association between prior treatment and the later covariate, an association between that covariate and later treatment, and a meaningful relationship between the covariate and outcome. These are substantive diagnostics, not proof of bias by themselves. Also inspect treatment frequencies within observed histories: very small probabilities of either treatment level indicate limited support for comparisons within those histories. Here the probabilities are 0.2 or 0.8, so positivity holds, though the example does not imply that such favorable overlap is typical.
The usual alternatives answer different questions. A crude comparison does not account for the observed treatment history. A conventional outcome regression can adjust for measured covariates, but its coefficients depend on the adjustment set and model form. The g-formula targets regime means by averaging over covariate distributions that arise under the regime; the first worked example used precisely that averaging step. Inverse-probability weighting is another standard approach for longitudinal treatment histories, but it is not needed to calculate this finite example.
The example is limited by its binary variables, simple assignment probabilities, and deterministic additive outcome equation. Real outcomes may be continuous or censored, treatment effects may vary across patients, and important confounders may be unmeasured. The calculations establish what happens under the stated model; they do not establish that a real study satisfies that model. Most importantly, a regression coefficient should not be called a causal effect solely because treatment precedes outcome or because some covariates appear in the regression.
Check Your Understanding
Answer each question using the numerical model above. Short solutions are included after the questions.
- What is the mean outcome under the regime \(A_1=1,A_2=0\)?
- What is the causal effect of changing \(A_2\) from 0 to 1 when \(A_1=0\) is fixed?
- Why does the regression of \(Y\) on \(A_1,A_2\), omitting \(L_2\), have an \(A_2\) coefficient different from the regime contrast?
- What is the crude observed mean difference \(E[Y\mid A_2=1]-E[Y\mid A_2=0]\), and what is its sign?
Solutions. (1) The regime mean is \(14-5(1)-2(0)=9\). (2) The regime mean changes by \((14-5-2)-(14-5)=-2\). (3) Severity predicts later treatment and raises the outcome; omitting it leaves a severity-related component in the regression coefficient, giving \(7/34\) rather than \(-2\). (4) The crude difference is \(11.36-9.64=1.72\), which is positive.