Tutorials › Marginal Structural Models › Sensitivity Analysis Across Model Specifications

The Parametric g-Formula · Tutorial 318 of 501

Sensitivity Analysis Across Model Specifications

You will learn to vary one modeling choice at a time, recompute the same standardized regime contrast, and interpret differences as evidence about model dependence rather than as a search for a preferred answer.

Advanced 12 min read

What You'll Learn

  • Define a fixed target estimand before comparing parametric g-formula specifications.
  • Calculate and interpret changes in standardized risks and risk differences across link functions.
  • Assess the effect of adding interaction terms without changing the target population.
  • Show how different transition distributions can change a nonlinear outcome estimate despite matching moments.
  • Separate model-specification sensitivity from Monte Carlo error and sampling uncertainty.
  • Use diagnostics and sensitivity tables to identify extrapolation and fragile conclusions.

Why Compare Model Specifications?

The parametric g-formula turns models for longitudinal covariate transitions and outcomes into regime-specific population summaries. Those summaries depend not only on the intervention regime and target population, but also on modeling choices: a logistic rather than probit link, a linear rather than transformed covariate effect, an interaction term, or a different distribution for a continuous transition. Sensitivity analysis asks whether the substantive conclusion persists across plausible choices.

A comparison is interpretable only when the quantity being compared is held fixed. Keep the target population, treatment regimes, follow-up horizon, outcome definition, and standardization procedure the same. Vary a specified modeling choice and report the resulting change. A model that changes both the estimand and the specification does not isolate model dependence.

Definition: Let \(m\) index a candidate collection of parametric models for the conditional outcome and covariate-transition distributions. For a regime \(\bar a\), let \(\psi_m(\bar a)\) be the regime-specific mean or risk obtained by applying those models in the parametric g-formula and averaging over the same target baseline distribution. For two regimes, the regime contrast is \(\Delta_m=\psi_m(\bar a)-\psi_m(\bar a')\) for a risk difference, or the corresponding fixed contrast on another prespecified scale. Sensitivity across specifications is the comparison of \(\psi_m\) or \(\Delta_m\) across plausible \(m\).

For a finite set of possible histories, the calculation can be written as a sum. Write \(L_t\) for time-varying covariates, \(Y\) for the outcome, and \(p_0(l_0)\) for the target baseline distribution. A candidate specification \(m\) supplies conditional transition distributions \(p_{m,t}(l_t\mid \bar l_{t-1},\bar a_{t-1})\) and an outcome regression \(\mu_m(\bar l_T,\bar a_T)=E_m[Y\mid \bar L_T=\bar l_T,\bar A_T=\bar a_T]\). Then

$$ \psi_m(\bar a)= \sum_{l_0,\ldots,l_T} \mu_m(\bar l_T,\bar a_T)\, p_0(l_0) \prod_{t=1}^{T}p_{m,t}(l_t\mid \bar l_{t-1},\bar a_{t-1}). $$

For continuous covariates, the corresponding sum is an integral. In practice, it may be evaluated by simulation. The uncertainty arising from finite data and the variation arising from simulation are distinct from the sensitivity comparison itself; simulation size and Monte Carlo error are treated in their own right.

Conditions for an Interpretable Comparison

The causal interpretation of each regime-specific quantity requires the usual identification conditions for the parametric g-formula: consistency, sequential exchangeability given the measured history, and positivity for the regimes and histories relevant to the target population. In addition, the fitted conditional models must represent the relevant outcome and transition distributions well enough for the g-formula calculation. Sensitivity analysis does not establish these conditions. In particular, agreement among several models cannot rule out unmeasured confounding or shared misspecification.

The comparison also needs a fixed target baseline distribution. One can average each model over the same empirical baseline covariates or over a specified population distribution, but switching target populations between specifications confounds model sensitivity with population composition. Fit each candidate to the same analytic sample when that is appropriate, use the same regime definitions, and state which features are changed. A staged comparison—first links, then functional forms, then interactions, then transition distributions—makes the source of a change easier to identify.

Worked Example: Link Function and Standardized Risk Difference

Suppose the target population has a binary baseline covariate \(X\), with \(P(X=1)=P(X=0)=0.5\). Compare two candidate outcome models for a binary outcome under treatment \(A\). The first is logistic, with \(\operatorname{logit}P(Y=1\mid A,X)=-2+0.8A+0.7X\). The second is probit, with \(P(Y=1\mid A,X)=\Phi(-1.5+0.6A+0.5X)\), where \(\Phi\) is the standard normal distribution function. The displayed coefficients are illustrative fitted values. In an applied analysis, both specifications would be fitted to the same data.

For the logistic model, the four conditional risks are \(P(Y=1\mid A=0,X=0)=\operatorname{expit}(-2)=0.119203\), \(P(Y=1\mid A=0,X=1)=\operatorname{expit}(-1.3)=0.214165\), \(P(Y=1\mid A=1,X=0)=\operatorname{expit}(-1.2)=0.231475\), and \(P(Y=1\mid A=1,X=1)=\operatorname{expit}(-0.5)=0.377541\). Standardizing over the two equally weighted baseline strata gives

$$ \psi_{\mathrm{logit}}(0)=\frac{0.119203+0.214165}{2}=0.166684,\qquad \psi_{\mathrm{logit}}(1)=\frac{0.231475+0.377541}{2}=0.304508, \qquad \Delta_{\mathrm{logit}}=0.304508-0.166684=0.137824. $$

For the probit model, the predictors in the same order are \(-1.5,-1.0,-0.9,-0.4\). The corresponding standard normal probabilities are approximately \(0.066807,0.158655,0.184060,0.344578\). Therefore \(\psi_{\mathrm{probit}}(0)=(0.066807+0.158655)/2=0.112731\), \(\psi_{\mathrm{probit}}(1)=(0.184060+0.344578)/2=0.264319\), and \(\Delta_{\mathrm{probit}}=0.264319-0.112731=0.151588\). The estimated risk difference differs by about \(0.013764\) between these illustrative specifications. This is a comparison of standardized risks, not a comparison of the raw coefficients: logistic and probit coefficients are on different latent scales.

Functional Form and Interactions

A link function determines how the linear predictor maps to a conditional mean. Transformations determine how a covariate enters that predictor: for example, \(L\), \(\log(L+c)\), or a spline basis. Interactions allow the association of one variable with the outcome to vary with another. These are distinct choices, although more than one may be changed in a candidate model. For a clean sensitivity analysis, vary them separately where feasible and then examine a small number of defensible combined specifications.

Worked Example: Adding a Treatment-by-Covariate Interaction

Use the same target population, with \(P(X=1)=0.5\), and the logistic model from the preceding example as the no-interaction specification. Now add a treatment-by-covariate interaction with coefficient \(-0.5\): \(\operatorname{logit}P(Y=1\mid A,X)=-2+0.8A+0.7X-0.5AX\). For \(A=0\), the predictors remain \(-2\) and \(-1.3\), so the standardized risk is \((0.119203+0.214165)/2=0.166684\).

For \(A=1,X=0\), the predictor is \(-2+0.8=-1.2\), giving risk \(0.231475\). For \(A=1,X=1\), it is \(-2+0.8+0.7-0.5=-1.0\), giving risk \(0.268941\). Thus \(\psi_{\mathrm{interaction}}(1)=(0.231475+0.268941)/2=0.250208\) and \(\Delta_{\mathrm{interaction}}=0.250208-0.166684=0.083524\). The no-interaction risk difference was \(0.137824\); adding this particular interaction lowers it by approximately \(0.054300\). The calculation shows why an interaction can matter after standardization, even though the target population and treatment regimes have not changed.

This numerical difference alone does not establish that the interaction model is better. The interaction should be scientifically plausible, estimable from the available data, and assessed alongside fit and support. If few observations occur in a treatment-by-covariate combination, the model may be relying heavily on extrapolation there.

Transition Distributions and Nonlinear Averaging

Sensitivity to a transition distribution can arise even when two candidate distributions agree on their mean and variance. The reason is that the g-formula averages the outcome regression over the full distribution of the covariate, not just its first two moments. Under a nonlinear outcome model, changing the distribution's shape can change the average predicted outcome.

Worked Example: Same Transition Moments, Different Outcome Risks

Consider a one-period setting with post-treatment covariate \(L\) and outcome model \(P(Y=1\mid A,L)=\operatorname{expit}(-2+0.5A+L)\). Suppose two candidate transition specifications are used under each treatment level. Specification 1 assigns probability \(0.5\) to each of \(L=0\) and \(L=2\). Specification 2 assigns probabilities \(0.125,0.75,0.125\) to \(L=-1,1,3\), respectively. Both have mean \(1\) and variance \(1\): for the second distribution, \(E[L]=-0.125+0.75+0.375=1\) and \(E[L^2]=0.125+0.75+1.125=2\), so \(\operatorname{Var}(L)=2-1^2=1\).

Under specification 1 and \(A=0\), the risks at \(L=0,2\) are \(\operatorname{expit}(-2)=0.119203\) and \(\operatorname{expit}(0)=0.5\). Their average is \(0.309601\). Under \(A=1\), the risks are \(\operatorname{expit}(-1.5)=0.182426\) and \(\operatorname{expit}(0.5)=0.622459\), giving risk \(0.402442\). The risk difference is \(0.402442-0.309601=0.092841\).

Under specification 2 and \(A=0\), the risks at \(L=-1,1,3\) are \(\operatorname{expit}(-3)=0.047426\), \(\operatorname{expit}(-1)=0.268941\), and \(\operatorname{expit}(1)=0.731059\). Weighting them gives \(0.125(0.047426)+0.75(0.268941)+0.125(0.731059)=0.299017\). For \(A=1\), the risks are \(\operatorname{expit}(-2.5)=0.075858\), \(\operatorname{expit}(-0.5)=0.377541\), and \(\operatorname{expit}(1.5)=0.817574\). The weighted risk is \(0.125(0.075858)+0.75(0.377541)+0.125(0.817574)=0.394835\). The risk difference is \(0.394835-0.299017=0.095818\), about \(0.002977\) above the first specification's result. Matching moments did not make the g-formula estimates identical.

Two Results for Interpreting Sensitivity

Result 1 (finite-support plug-in consistency): Suppose the baseline covariates and all longitudinal histories relevant to a fixed regime have finite support, the sample is independent and identically distributed, the candidate parameter estimators converge in probability to their population values, and each conditional probability or mean in the g-formula is a continuous function of those parameters at the population value. If the candidate models are correctly specified for those conditional distributions and the identification conditions hold, then the plug-in g-formula estimator \(\hat\psi_m(\bar a)\) converges in probability to the identified \(\psi(\bar a)\).

Proof. With finite support, the g-formula is a finite sum of products of baseline probabilities, transition probabilities, and conditional outcome means. Under independent and identically distributed sampling, each empirical baseline probability converges in probability to its population probability by the law of large numbers. By assumption, each estimated model parameter converges in probability to its population value; continuity then implies convergence in probability of every fitted conditional probability or mean at every support point. Products and finite sums preserve convergence in probability. Consequently, the plug-in sum converges to the g-formula evaluated at the true conditional distributions. Identification equates that quantity with the causal regime-specific mean. \(\square\)

This result explains what a correctly specified parametric g-formula estimates; it does not say that different incorrect models will agree, nor does it certify that a candidate is correctly specified. For continuous histories, analogous arguments require additional conditions, such as suitable domination and valid convergence of the relevant integrals. Those conditions should not be assumed merely because a simulation produces a number.

Result 2 (bound for a finite target population): Suppose the target baseline distribution has finite support \(x_1,\ldots,x_K\), with weights \(w_k\geq 0\) and \(\sum_{k=1}^K w_k=1\). For two candidate specifications \(m\) and \(m'\), let \(r_m(x_k)\) and \(r_{m'}(x_k)\) be their regime-specific conditional contributions after the remaining g-formula averaging. Then \(\left|\psi_m-\psi_{m'}\right|\leq\max_k|r_m(x_k)-r_{m'}(x_k)|\).

Proof. By standardization, \(\psi_m-\psi_{m'}=\sum_{k=1}^K w_k\{r_m(x_k)-r_{m'}(x_k)\}\). The triangle inequality gives \(\left|\psi_m-\psi_{m'}\right|\leq\sum_{k=1}^K w_k|r_m(x_k)-r_{m'}(x_k)|\). Each absolute difference is at most its maximum over \(k\), and the weights sum to one. Hence the last expression is at most \(\max_k|r_m(x_k)-r_{m'}(x_k)|\). \(\square\)

This bound is useful as a localization diagnostic: a large overall change must be supported by at least one target stratum with a substantial conditional change. A small overall change, however, may conceal offsetting changes across strata, so inspect the stratum-specific predictions as well as the marginal estimate.

Diagnostics, Comparisons, and Limitations

A disciplined comparison reports more than a collection of point estimates. Keep a record of which component changes in each specification and inspect model predictions in the histories that contribute to each regime. Useful warning signs include implausible predicted risks, sparse treatment-history combinations, extreme or unstable transition predictions, large changes concentrated in poorly supported strata, and sensitivity to a transformation or interaction that is not supported by the observed data. Diagnostics for parametric longitudinal models help assess individual model fit; sensitivity analysis complements them by showing how conclusions respond to alternative plausible specifications.

Compare the candidates on the same effect scale. A risk difference and a risk ratio can differ because of their scales even when based on the same risks; that is a change in contrast, not necessarily a change in model. Likewise, compare standardized regime risks before attributing a difference in a contrast to a particular model component. If every model predicts almost the same standardized risks but a reported contrast changes, check the contrast calculation.

Sensitivity analysis is not a formal model-selection rule. Choosing whichever specification gives the desired result is not defensible, and averaging estimates across models does not automatically account for model uncertainty. A useful report gives the primary specification and its rationale, a prespecified set of plausible alternatives, their standardized estimates, and a short explanation of where and why they differ. Sampling uncertainty is still relevant; a spread across specifications is not a confidence interval. Bootstrap inference for g-computation addresses sampling variability, not the choice of model specification.

Common Pitfall

Wrong reasoning: “The estimates from two models are close, so the causal conclusion is robust.” This overlooks the possibility that both models share the same omitted nonlinearity, unsupported extrapolation, or misspecified transition mechanism. Conversely, a difference between models does not by itself show which one is correct.

Correction: Interpret closeness as limited sensitivity to the particular choices examined, not as proof of validity. Check the relevant assumptions and diagnostics, add alternatives that probe scientifically plausible departures, and locate any differences in the histories that drive the g-formula. State explicitly which dimensions of specification were varied and which were not.

Check Your Understanding

Use these questions to check whether the sensitivity comparison is targeting what you intend. Brief solutions follow.

  1. Why must the target baseline distribution remain fixed when comparing two fitted outcome specifications?
  2. In the interaction example, what is the treatment risk at \(X=1\) under the interaction model, and why does it differ from the no-interaction risk?
  3. Two candidate transition distributions have identical means and variances. Does that guarantee identical g-formula risks? Explain.
  4. A marginal estimate changes little across two models, but some stratum-specific predictions change substantially. What should be reported or investigated?
  5. Does agreement across several candidate specifications establish sequential exchangeability?

Solutions. (1) Otherwise a difference combines model dependence with a change in target population. (2) Its predictor is \(-1.0\), so its risk is \(\operatorname{expit}(-1)=0.268941\); the interaction changes the predictor by \(-0.5\) only when both \(A=1\) and \(X=1\). (3) No. A nonlinear outcome regression is averaged over the full transition distribution, and different shapes can give different averages even when the first two moments agree. (4) Report the stratum-specific predictions and weights, then investigate cancellation, support, and extrapolation; a stable marginal result can mask unstable components. (5) No. Agreement is evidence only about the alternatives examined and cannot establish an identification assumption such as sequential exchangeability.

Clinical Biostats