Tutorials › Causal Inference › End-To-End G-Estimation Analysis Workshop

Structural Nested Models and G-Estimation · Tutorial 776 of 972

End-To-End G-Estimation Analysis Workshop

Learn how to specify, estimate, check, and report a longitudinal structural nested model using g-estimation.

Advanced 12 min read

What You'll Learn

  • Define treatment histories and blip functions for a longitudinal analysis
  • State the assumptions that support g-estimation
  • Use a treatment-residual score to estimate a blip parameter
  • Estimate treatment effects sequentially from the final visit backward
  • Diagnose treatment variation and blip-model fit
  • Report uncertainty and interpret estimates in context

From a Longitudinal Question to an Analysis Plan

A longitudinal g-estimation analysis is not a single regression. It is a sequence of decisions: define the treatment history, specify the causal contrast represented by each blip, state the identification assumptions, estimate the blip parameters using treatment assignment conditional on observed history, and then assess whether the model and available treatment variation support the conclusions. Keeping these steps explicit helps distinguish a causal estimate from a coefficient that merely describes an adjusted association.

Consider a hypothetical study in which patients may receive treatment at two visits. Let \(A_1\) and \(A_2\) denote treatment at visits 1 and 2, with values 0 or 1. Let \(L_1\) be measured before the first treatment and \(L_2\) be measured after visit 1 but before the second treatment. The observed outcome \(Y\) is measured after visit 2. The treatment history available just before visit 1 is \(H_1=L_1\); just before visit 2 it is \(H_2=(L_1,A_1,L_2)\). In particular, \(L_2\) may be affected by \(A_1\) and may influence both \(A_2\) and \(Y\). That is treatment-confounder feedback.

A structural nested mean model describes the mean outcome contrast, or blip, associated with changing treatment at a particular time while holding the relevant history fixed. For a simple additive model, write the blip at visit \(t\) as \(A_t\gamma_t\). Here \(\gamma_t\) is the mean outcome change associated with treatment at visit \(t\), on the outcome scale and under the model’s specified history structure. More flexible blips can depend on history, for example \(A_t\{\gamma_{t0}+\gamma_{t1}L_t\}\); the history terms and their interpretation must be chosen in advance.

Definition: A blip function specifies the modeled causal contrast for changing treatment at one time point, conditional on the history available before that treatment. A blipped-down outcome subtracts the modeled treatment blips from the observed outcome. At the correct blip parameters, the transformed outcome should have no remaining conditional mean association with the treatment being tested, given its pre-treatment history.

For the additive two-visit illustration, the full transformed outcome is \(U=Y-\gamma_1A_1-\gamma_2A_2\). Estimation proceeds backward in time: first find \(\gamma_2\), using the visit-2 history; then subtract the estimated visit-2 blip and estimate \(\gamma_1\), using the visit-1 history. This order matters because the visit-2 treatment occurs after visit 1 and its effect must be removed before testing the visit-1 treatment.

Assumptions Before Estimation

The causal interpretation of g-estimation depends on assumptions about how treatments were assigned and how the observed data represent the counterfactual outcomes of interest. For this workshop, use the following standard conditions.

  • Consistency: each patient’s observed outcome under the treatment history actually received equals the corresponding counterfactual outcome. Treatment versions must be sufficiently well defined for this statement to be meaningful.
  • No interference: one patient’s treatment history does not change another patient’s outcome.
  • Sequential exchangeability: at each visit, conditional on the measured pre-treatment history \(H_t\), treatment \(A_t\) is independent of the counterfactual outcomes relevant to the analysis. Unmeasured common causes of treatment and outcome violate this condition.
  • Positivity: within histories represented in the target population, there is support for the treatment options being compared. In a binary-treatment setting, this requires \(0<P(A_t=1\mid H_t)<1\) for the histories where the contrast is sought.
  • Correct blip specification: the chosen time structure, functional form, and effect-modification terms adequately represent the treatment contrasts being estimated.

A treatment model estimates \(p_t(H_t)=P(A_t=1\mid H_t)\). In a simple binary-treatment estimating equation, a correctly specified treatment model is needed to form the treatment residual \(A_t-\hat p_t(H_t)\). Correct blip specification and the causal assumptions remain necessary: a well-fitting treatment model cannot repair unmeasured confounding or a wrong causal contrast.

Sequential G-Estimation

At the final visit, the candidate blipped-down outcome is \(Q_2(\gamma_2)=Y-A_2\gamma_2\). Under the correct blip parameter and sequential exchangeability, its conditional mean should not vary with \(A_2\) after conditioning on \(H_2\). One way to express that restriction is a conditional moment equation. For binary treatment, a useful score is the treatment residual multiplied by the centered blipped-down outcome:

$$ \sum_{i=1}^{n} \{A_{i2}-\hat p_2(H_{i2})\} \{Q_{i2}(\gamma_2)-\hat m_2(H_{i2})\}=0. $$

Here \(\hat m_2(H_2)\) estimates the conditional mean of the transformed outcome given history. Centering can improve numerical behavior; with a correctly specified treatment probability, the key restriction is that the transformed outcome has no conditional mean association with treatment. For a history-dependent blip, replace \(A_2\gamma_2\) by the specified blip function and solve the corresponding estimating equation for its parameters.

After estimating the final-visit blip, define \(Q_1=Y-A_2\hat\gamma_2\), then use the visit-1 restriction to estimate \(\gamma_1\). More generally, with several visits, move backward: remove estimated blips for later treatments before estimating the blip at the current visit. This construction avoids treating \(L_2\), which may be affected by \(A_1\), as if it were an ordinary baseline confounder in a single outcome regression.

Worked Example: Defining the Histories and Blips

Suppose a hypothetical study records baseline severity \(L_1\), treatment \(A_1\), follow-up severity \(L_2\), treatment \(A_2\), and a final symptom score \(Y\), where lower scores indicate fewer symptoms. The outcome is measured in points. Specify the histories and a simple blip model.

Before visit 1, the observed history is \(H_1=L_1\). Before visit 2, it is \(H_2=(L_1,A_1,L_2)\). The latter includes \(A_1\) because it has occurred, and \(L_2\) because it is measured before the second treatment. A simple model is \(A_1\gamma_1\) for the first-visit blip and \(A_2\gamma_2\) for the second-visit blip. The full transformed outcome is therefore \(Y-A_1\gamma_1-A_2\gamma_2\).

If treatment at visit 2 is expected to work differently at different levels of \(L_2\), a prespecified alternative could use \(A_2(\gamma_{20}+\gamma_{21}L_2)\). The coefficient \(\gamma_{21}\) then describes how the visit-2 treatment contrast changes per unit of baseline-for-visit-2 severity; it is not a separate overall treatment effect. The model, history, and units must be reported so that the contrast is interpretable.

A Worked Visit-2 Estimation

A transparent special case is a categorical history stratum in which the visit-2 treatment contrast is estimated within strata. It illustrates the same central g-estimation idea: choose the blip so that the blipped-down outcome no longer differs by treatment within pre-treatment history. The following cell summaries are hypothetical.

Worked Example: Removing the Visit-2 Treatment Association

Suppose the visit-2 history has two strata. In stratum 0, 20 patients received treatment and had mean outcome 14 points; 20 did not and had mean outcome 11 points. In stratum 1, 30 received treatment and had mean outcome 20 points; 10 did not and had mean outcome 17 points. Estimate a common additive visit-2 blip.

Within stratum 0, the treated-minus-untreated outcome contrast is \(14-11=3\) points. Within stratum 1, it is \(20-17=3\) points. Subtracting a 3-point blip from each treated outcome makes the treated and untreated mean transformed outcomes equal in both strata: \(14-3=11\) and \(20-3=17\). Thus \(\hat\gamma_2=3\) points under the common-blip model.

The estimated treatment probabilities are \(20/40=0.50\) in stratum 0 and \(30/40=0.75\) in stratum 1. The positive treatment counts in both strata provide observed treatment variation, although a full analysis would also inspect the distributions of the histories and propensity estimates. This calculation does not establish exchangeability or correct specification; it only shows how the stated summaries satisfy the within-stratum blip restriction.

Estimation, Diagnostics, and Uncertainty

In a real analysis, histories are usually richer than two strata, so the treatment probability and conditional transformed-outcome models are estimated from patient-level data. The fitted treatment probabilities should be checked for extreme values, sparse history regions, and near-deterministic treatment. These are practical signs of weak positivity: an estimate may be numerically available but rely heavily on extrapolation. Inspect treatment counts across clinically meaningful histories, not only a single overall treatment proportion.

Blip-model diagnostics should also be tied to the model’s restrictions. After estimating a blip, examine whether the blipped-down outcome retains a treatment association within relevant history strata or through prespecified residual checks. Investigate whether the assumed common effect masks systematic differences over time or across history. Such checks can reveal incompatibility with the proposed model, but passing them does not prove the model correct or rule out unmeasured confounding.

Uncertainty must account for the estimation procedure, including fitted treatment models and sequential estimation. A suitable sandwich variance or patient-level bootstrap can be used when justified for the estimator and study design. For a bootstrap, resample patients (or the appropriate independent sampling units), refit all nuisance models, and repeat every backward g-estimation step in each resample. Resampling only the final coefficient while treating earlier fitted quantities as fixed generally understates uncertainty.

Worked Example: Reporting Estimates and Uncertainty

In a hypothetical two-visit analysis, suppose the sequential g-estimates are \(\hat\gamma_1=2.0\) points and \(\hat\gamma_2=3.0\) points. A patient-level bootstrap that repeats the full estimation procedure gives standard errors of 0.80 and 0.90 points, respectively. For illustration, use normal-approximation 95% confidence intervals.

For visit 1, the interval is \(2.0\pm1.96(0.80)=2.0\pm1.568\), or \((0.432,3.568)\) points. The Wald statistic for testing a zero blip is \(2.0/0.80=2.50\), giving a two-sided normal-approximation p-value of about 0.0124. For visit 2, the interval is \(3.0\pm1.96(0.90)=3.0\pm1.764\), or \((1.236,4.764)\) points. Its Wald statistic is \(3.0/0.90=3.33\), with a two-sided p-value of about 0.00086.

Under the model and identification assumptions, the estimates represent positive mean outcome contrasts of 2.0 points for the first-visit blip and 3.0 points for the second-visit blip on the specified scale. Because lower symptom scores are better, the positive values indicate higher, not lower, scores under treatment as coded. The intervals describe uncertainty from repeated sampling under the analysis procedure; they are not probabilities that fixed parameters lie in these particular intervals. The numerical results alone do not establish that the assumptions hold.

Putting the Analysis Together

A disciplined report lets a reader trace each causal claim to its model and assumptions. State the target population and outcome scale; define the treatment histories and time points; give the blip functions and any effect-modification terms; describe the treatment models and estimation order; report treatment-variation and model diagnostics; and provide estimates with uncertainty in context. Explain how missingness or censoring was handled if it is present, rather than assuming it disappears through g-estimation.

1
Define the target contrast.
Name the outcome, treatment options, time points, and causal blips to be estimated.
2
Build each pre-treatment history.
Include measured variables available before that visit’s treatment, distinguishing them from post-treatment variables.
3
State assumptions and models.
Address consistency, no interference, sequential exchangeability, positivity, and the blip and treatment-model specifications.
4
Estimate backward and check.
Estimate the final blip first, remove it, proceed to earlier visits, and inspect treatment support and residual treatment associations.
5
Quantify and interpret uncertainty.
Use an appropriate variance method that reflects the full procedure, then interpret each estimate on its outcome scale and in its clinical context.

Common Mistake: Treating a Blip as an Ordinary Regression Coefficient

A common error is to fit a regression of \(Y\) on \(A_1\), \(A_2\), and \(L_2\), then call the treatment coefficients causal effects. That reasoning can fail because \(L_2\) may be affected by \(A_1\) while confounding the relationship between \(A_2\) and \(Y\). Ordinary adjustment for \(L_2\) can change the target contrast and does not, by itself, resolve treatment-confounder feedback. The correction is to specify the longitudinal blips and histories, state the sequential identification assumptions, and use the g-estimation restrictions to remove later treatment effects before estimating earlier ones.

Key takeaway: G-estimation is a sequential causal procedure, not simply a regression with many covariates. Its interpretation depends on a clearly defined blip model, measured pre-treatment histories, adequate treatment variation, and defensible identification assumptions.

Check Your Understanding

Use the two-visit setup above to check your understanding of the analysis workflow.

  1. What variables belong in \(H_2\), and why can \(L_2\) be both affected by prior treatment and a confounder of later treatment?
  2. Why is the visit-2 blip estimated before the visit-1 blip?
  3. In the visit-2 example, what transformed treated mean is obtained in each history stratum when the estimated blip is subtracted?
  4. What does a near-zero or near-one estimated treatment probability within a history region suggest?
  5. Why does a correctly fitted treatment-probability model not eliminate the need for sequential exchangeability?
  6. What must a patient-level bootstrap repeat to reflect uncertainty in the complete sequential estimation procedure?
Clinical Biostats