Tutorials › Marginal Structural Models › Worked Example With CD4 Count And Antiretroviral Therapy

Time-Varying Treatments and Confounder Feedback · Tutorial 17 of 501

Worked Example With CD4 Count And Antiretroviral Therapy

Trace how repeated CD4 counts link prior therapy to later treatment and survival, and see numerically why adjusting for CD4 can change the question a regression answers.

Intermediate 12 min read

What You'll Learn

  • Represent repeated CD4 counts and antiretroviral treatment in their time order.
  • Explain why a later CD4 count can be both affected by earlier treatment and predictive of later treatment and survival.
  • Calculate a total effect of prior therapy and distinguish it from a conditional regression contrast.
  • Quantify how low CD4 can confound the observed association between later therapy and mortality.
  • Identify diagnostics and limitations of ordinary regression adjustment in this setting.

Following CD4 Count and Treatment Through Time

Antiretroviral therapy (ART) decisions are made in response to a patient’s health, and treatment can itself change that health. This creates a clinically important feedback pattern: earlier ART may improve CD4 count, while the resulting CD4 count helps determine later ART and predicts survival. A regression that adjusts for CD4 without regard to when it was measured can therefore alter the comparison it is meant to make.

Consider two treatment decisions. Let \(A_0\) indicate ART at the first visit and \(A_1\) ART at a later visit. Let \(L_1\) denote the CD4 count measured after the first decision but before the second. Let \(Y=1\) indicate death by the end of follow-up, and \(Y=0\) indicate survival. A low CD4 count is prognostic for death and may prompt ART; the count \(L_1\) can also have been changed by \(A_0\).

Definition: In this two-decision example, \(L_1\) is a time-varying confounder for the association between \(A_1\) and \(Y\) if it predicts later treatment and the outcome, conditional on the relevant history. It is also affected by prior treatment if the distribution of \(L_1\) would differ under different values of \(A_0\). This combination is treatment-confounder feedback.

The ordering matters: \(A_0\) occurs before \(L_1\), and \(L_1\) occurs before \(A_1\). Adjusting for a measurement made before the treatment decision is not the same operation as adjusting for a measurement made after it. The point here is not that CD4 should never be adjusted for; it is that the target comparison and timing must be specified first.

A Clinical Timeline

Worked Example: Reading Repeated CD4 Counts

Suppose three patients have the following recorded histories. CD4 counts are in cells per microliter, and the outcome is death during follow-up.

PatientBaseline CD4ART at first visit \(A_0\)CD4 before later decision \(L_1\)ART at later visit \(A_1\)Outcome \(Y\)
1170Yes240Yes0
2170No120Yes1
3360No330No0

For Patient 1, the first treatment decision precedes the increase from 170 to 240. That sequence is consistent with a treatment effect on CD4, though one patient’s observed history cannot establish that effect. Patient 2 has a low later CD4 count and receives later ART; the count could influence both the treatment decision and mortality. Patient 3 has a higher count and does not receive later ART.

The table illustrates the roles of the variables, not a treatment-effect estimate. In particular, comparing Patient 1 with Patient 2 would mix their different treatment histories, CD4 trajectories, and other possible differences. A causal interpretation requires explicit assumptions and a suitable comparison, not just a sequence that looks clinically plausible.

A Numerical Model for the Feedback

To make the adjustment issue exact, consider a simple hypothetical population. For this example, let \(L_1=1\) mean CD4 is low (below a chosen threshold) and \(L_1=0\) mean it is not low. Let \(U\) be a binary baseline severity factor, with \(P(U=1)=0.5\). Suppose \(A_0\) is randomized independently of \(U\), and the probability of low CD4 is:

First-visit treatment \(A_0\)\(P(L_1=1\mid U=0,A_0)\)\(P(L_1=1\mid U=1,A_0)\)\(P(L_1=1\mid A_0)\)
00.20.80.5
10.10.50.3

The last column averages over \(U\). For example, when \(A_0=0\), it is \(0.5(0.2)+0.5(0.8)=0.5\). When \(A_0=1\), it is \(0.5(0.1)+0.5(0.5)=0.3\). Thus earlier therapy changes the distribution of the later CD4 indicator in this model.

Suppose the later treatment decision follows \(P(A_1=1\mid L_1=1)=0.8\) and \(P(A_1=1\mid L_1=0)=0.2\). Assume the outcome model is:

$$ P(Y=1\mid A_0,A_1,L_1)=0.30+0.10L_1-0.08A_0-0.15A_1. $$

This is a hypothetical conditional risk model, not a claim about an actual clinical effect size. Its risks range from 0.07 to 0.40, so all are valid probabilities. In the model, low CD4 increases mortality risk, and both ART decisions reduce it. Assume the outcome random variation is independent of the treatment-assignment random variation conditional on the variables shown. Since \(U\) has no additional effect on the outcome once these variables are given, the displayed history suffices for the calculations below.

Worked Example: Total Effect of First-Visit ART

Compare the two interventions that set \(A_0\) to 1 or 0 while fixing \(A_1=b\), where \(b\) can be either 0 or 1. The mean mortality risk under each intervention averages over the CD4 distribution that results from that value of \(A_0\).

When \(A_0=0\), \(P(L_1=1)=0.5\), so:

$$ E[Y\mid do(A_0=0,A_1=b)] =0.30+0.10(0.5)-0.08(0)-0.15b =0.35-0.15b. $$

When \(A_0=1\), \(P(L_1=1)=0.3\), giving:

$$ E[Y\mid do(A_0=1,A_1=b)] =0.30+0.10(0.3)-0.08(1)-0.15b =0.25-0.15b. $$

Subtracting the first risk from the second gives \(0.25-0.15b-(0.35-0.15b)=-0.10\). Thus, in this model, first-visit ART lowers mortality risk by 0.10 under either fixed later-treatment value. Of that difference, \(-0.08\) is the direct term in the outcome model and \(-0.02\) comes from the lower probability of low CD4: \(0.10(0.3-0.5)=-0.02\). For survival, defined as \(1-Y\), the corresponding total effect is an increase of 0.10 in survival probability.

Why Conditioning on CD4 Changes the First-Treatment Contrast

Result: Under the stated risk model, the conditional mortality contrast for \(A_0\), holding \(L_1\) and \(A_1\) fixed, is \(-0.08\). The marginal contrast under interventions fixing \(A_1\) is \(-0.10\), because it also includes the change in the distribution of \(L_1\).

Derivation. At fixed \(L_1=l\) and \(A_1=b\), the model gives:

$$ P(Y=1\mid A_0=1,A_1=b,L_1=l) - P(Y=1\mid A_0=0,A_1=b,L_1=l) =-0.08. $$

This follows by subtracting the two expressions: the common terms \(0.30+0.10l-0.15b\) cancel, leaving \(-0.08\). The marginal contrast instead averages over different CD4 distributions under the two first-visit interventions. Its value is:

$$ -0.08+0.10\{P(L_1=1\mid do(A_0=1))-P(L_1=1\mid do(A_0=0))\} =-0.08+0.10(0.3-0.5) =-0.10. $$

The derivation is complete for the specified model: the risk is linear in \(L_1\), and the only change in the distribution of \(L_1\) is the difference in its low-count probability. More generally, conditional and marginal contrasts need not have this simple additive relationship. The important lesson is that conditioning on \(L_1\) holds fixed a variable that can carry part of the effect of \(A_0\).

Why Low CD4 Confounds the Later-Treatment Comparison

The same model shows why comparing later ART recipients with nonrecipients can mislead. Within a stratum of \(A_0\), later ART is more common when CD4 is low, and low CD4 predicts death. The treatment groups therefore differ in prognosis even before any effect of \(A_1\) is considered.

Result: Within a fixed value of \(A_0\), the unadjusted mortality risk difference comparing \(A_1=1\) with \(A_1=0\) equals \(-0.15+0.10\) times the difference in low-CD4 prevalence between those treatment groups. It equals the model’s \(-0.15\) treatment contrast only when the prevalence difference is zero or the CD4 risk coefficient is zero.

Derivation. Write \(q_1=P(L_1=1\mid A_1=1,A_0=a)\) and \(q_0=P(L_1=1\mid A_1=0,A_0=a)\). Averaging the outcome model within the two treatment groups while holding \(A_0=a\) fixed gives risks that differ by:

$$ \begin{aligned} &E[Y\mid A_1=1,A_0=a]-E[Y\mid A_1=0,A_0=a]\\ &\qquad=-0.15+0.10(q_1-q_0). \end{aligned} $$

The \(A_0\) term cancels because the comparison is within its stratum. The additional term is the difference in CD4 composition multiplied by CD4’s coefficient in the risk model.

Worked Example: The Later-Treatment Association Within Each First-Treatment Group

For \(A_0=0\), the low-CD4 prevalence is 0.5. The probability of receiving \(A_1=1\) is \(0.5(0.8)+0.5(0.2)=0.5\). Among those receiving later ART, the low-CD4 proportion is \(0.5(0.8)/0.5=0.8\). Among those not receiving it, that proportion is \(0.5(0.2)/0.5=0.2\). Therefore the observed mortality risk difference is:

$$ -0.15+0.10(0.8-0.2)=-0.09. $$

For \(A_0=1\), the low-CD4 prevalence is 0.3. The chance of later ART is \(0.3(0.8)+0.7(0.2)=0.38\). Among later-treatment recipients, the low-CD4 proportion is \(0.24/0.38=12/19\). Among nonrecipients, it is \(0.06/0.62=3/31\). The risk difference is:

$$ -0.15+0.10\left(\frac{12}{19}-\frac{3}{31}\right) =-0.15+0.10\left(\frac{315}{589}\right) \approx -0.0965. $$

Both crude differences are closer to zero than the conditional model contrast of \(-0.15\), because the treated groups include more patients with low CD4 and higher predicted mortality. In this specified model, correctly conditioning on \(L_1\) removes that particular imbalance for the \(A_1\) contrast. It does not follow that the same adjustment makes the \(A_0\) coefficient a total effect.

Assumptions, Diagnostics, and Alternatives

The calculations above are causal only under assumptions matching the example. Consistency requires each patient’s observed outcome under the treatment actually received to agree with the corresponding potential outcome. The first treatment must be randomized, or adequately controlled for by measured baseline history. For the later decision, sequential exchangeability requires that, conditional on the measured past including \(A_0\) and \(L_1\), treatment assignment carries no further information about potential outcomes. Positivity requires a nonzero chance of each later treatment option in each history being compared. The numerical example satisfies these conditions by construction; clinical data may not.

Useful diagnostics begin with the timeline and the data, not with a preferred regression formula. Check that CD4 is recorded before the later treatment decision; summarize later-treatment frequencies across CD4 levels and earlier-treatment histories; and look for histories with almost no patients receiving one treatment option. Very sparse histories indicate a positivity problem. Also inspect whether the CD4-outcome and CD4-treatment relationships are adequately represented: a linear term for a continuous count may be inappropriate if risk changes sharply near a clinical threshold.

No diagnostic plot can establish that all confounders were measured or that treatment assignment is exchangeable. The calculations also do not account for treatment changes between visits, measurement error in CD4, informative loss to follow-up, or effect modification. Those features require an expanded analysis rather than an uncritical extension of this two-decision example.

ApproachWhat it comparesKey caution in this example
Baseline-only adjustmentPatients with different later treatment, adjusted only for baseline informationIt leaves the later CD4 imbalance uncontrolled.
Regression conditional on \(A_0\) and \(L_1\)Later-treatment groups with the same measured CD4 and first-treatment historyIt can address later-treatment confounding under suitable assumptions, but the \(A_0\) coefficient conditions on a variable affected by \(A_0\).
Marginal regime comparisonOutcomes under specified treatment histories, averaged over the target populationIt targets a population-level contrast; its validity still depends on consistency, exchangeability, and positivity.

A common mistake is to say, “CD4 predicts death, so adjust for it in every treatment-effect regression.” That reasoning notices CD4’s prognostic role but ignores its timing. For the later-treatment comparison, \(L_1\) can be needed to control confounding by indication. For the earlier-treatment comparison, holding \(L_1\) fixed can remove the part of the total effect that operates through CD4. A coefficient from a single adjusted regression is not automatically the effect of a treatment history.

Key takeaway: In repeated ART decisions, a CD4 count measured between visits can be both a consequence of prior therapy and a cause of later treatment. Its role depends on which treatment contrast is being estimated; the same adjustment can help one comparison while changing another.

Check Your Understanding

Use the model and definitions above. The solutions are included so that each calculation can be checked.

  1. Under the model, what is the mortality risk under \(A_0=0,A_1=1\), averaging over the resulting CD4 distribution?
  2. Why is the within-\(A_0=0\) crude later-treatment risk difference \(-0.09\), rather than \(-0.15\)?
  3. Which part of the total first-treatment effect is removed by conditioning on \(L_1\) in this example?
  4. Name two assumptions needed to interpret the comparisons causally, and explain one diagnostic for positivity.

Solutions. (1) With \(A_0=0\), the low-CD4 probability is 0.5, so the risk is \(0.30+0.10(0.5)-0.15=0.20\). (2) The later-treatment group has low-CD4 prevalence 0.8, compared with 0.2 among nonrecipients. Thus the difference is \(-0.15+0.10(0.8-0.2)=-0.09\). (3) Conditioning on \(L_1\) removes the mediated component \(0.10(0.3-0.5)=-0.02\), leaving the conditional contrast \(-0.08\) rather than the total contrast \(-0.10\). (4) Examples include consistency, sequential exchangeability, and positivity. To assess positivity, tabulate treatment frequencies across CD4 levels and prior-treatment histories; a history with zero or nearly zero probability of one treatment option signals a violation or serious practical weakness.

Clinical Biostats