Why Diagnose the Conditional Models?
The parametric g-formula relies on models for the successive covariate transitions and the outcome, conditional on the histories that precede them. A model can produce a plausible marginal estimate while fitting important parts of those conditional distributions poorly. Diagnostics ask a more local question: does the fitted model describe the observed data at each step of the longitudinal process?
Write \(H_t\) for the observed history available immediately before a variable is generated at time \(t\). It may include baseline covariates, earlier covariates, and treatment history. For a binary covariate \(L_t\), for example, the fitted model gives \(\hat p_t(H_t)=\widehat P(L_t=1\mid H_t)\). For a continuous variable, it gives a fitted conditional distribution \(\hat F_t(\,\cdot\mid H_t)\). Diagnostics compare these conditional predictions with the observed \(L_t\) or outcome among people with the corresponding observed histories.
This is different from checking a counterfactual estimand directly. The observed data contain outcomes under received treatment, not outcomes under every intervention. A good fit to observed conditional distributions is useful, but it does not by itself establish exchangeability, positivity, or correctness of extrapolation to histories rarely or never observed.
Residuals and Their Reference Properties
These quantities have different uses. Raw residuals can reveal systematic overprediction or underprediction. Standardized residuals put errors on a common scale, while PIT values assess the whole conditional distribution rather than only its mean. Binary residuals cannot form a smooth bell-shaped histogram: their possible values depend on the predicted probability. For binary variables, calibration summaries and proper prediction scores are usually more informative than a normality check.
Proof. Since \(m(H)\) is a function of \(H\), conditional expectation gives \(E[R\mid H]=E[X-m(H)\mid H]=E[X\mid H]-m(H)=0\). Taking expectations of both sides and applying the law of total expectation yields \(E[R]=E\{E[R\mid H]\}=0\). The integrability assumption ensures these expectations exist. \(\square\)
This result motivates plotting residuals against fitted values, time, and important components of history. A trend in their conditional averages may signal a missing nonlinear term, an interaction, or another systematic feature. A zero overall average is not enough: positive and negative errors in different history groups can cancel.
Calibration and Distributional Checks
For a binary variable \(X\), calibration asks whether observations with predicted probability near \(p\) occur with frequency near \(p\). Under a correct conditional mean \(m(H)=P(X=1\mid H)\), the identity \(E[X\mid m(H)]=m(H)\) follows by conditioning first on \(H\) and then on \(m(H)\). In practice, predictions are grouped into bins or summarized with a smooth calibration curve. Bins should not be so narrow that they contain too few observations to estimate event frequencies reliably.
The Brier score, \(n^{-1}\sum_i(X_i-\hat p_i)^2\), summarizes squared probability error; lower is better on the same evaluation sample and for the same outcome prevalence. It does not identify the source of poor fit, so it should accompany calibration plots or subgroup summaries. For continuous outcomes, inspect residuals against fitted values and history, their spread across time or predicted values, and whether the assumed conditional distribution describes tails and interval coverage.
Proof. Fix \(u\) with \(0<u<1\), and define the conditional quantile \(q_u(H)=\inf\{x:F(x\mid H)\geq u\}\). Continuity of the conditional CDF implies \(F(q_u(H)\mid H)=u\). Thus, conditional on \(H\), \(P(U\leq u\mid H)=P(X\leq q_u(H)\mid H)=F(q_u(H)\mid H)=u\). This conditional probability is the same for every \(H\); taking expectations gives \(P(U\leq u)=u\). The endpoints follow by limits. \(\square\)
The implication is one-way as a diagnostic: a uniform-looking PIT histogram is compatible with a correct conditional distribution, but a small sample can make substantial departures hard to see. A uniform marginal histogram also does not guarantee that the distribution is correct within important history groups. For discrete variables, the ordinary PIT is not continuous-uniform; randomized PIT values, formed by drawing uniformly between the CDF values immediately below and at the observation, are a possible distributional check.
Worked Example: Binary Calibration and Brier Score
Suppose 20 observed covariate transitions fall into two prediction groups. In the first group, 10 people each have predicted probability \(0.20\), and 2 experience the transition. In the second, 10 each have predicted probability \(0.60\), and 8 experience it.
The observed event frequencies are \(2/10=0.20\) and \(8/10=0.80\). The first group agrees with its predictions; the second has 0.20 more events per person than predicted. Across all 20 people, the observed event rate is \(10/20=0.50\), whereas the mean prediction is \((10(0.20)+10(0.60))/20=0.40\). The overall difference is \(0.10\); it does not reveal which group drives the discrepancy.
The Brier score is \((2(1-0.20)^2+8(0-0.20)^2+8(1-0.60)^2+2(0-0.60)^2)/20\). The four contributions are \(1.28,\ 0.32,\ 1.28,\ 0.72\), respectively, so the score is \(3.60/20=0.18\). The calibration comparison points specifically to underprediction in the second group; the score alone would not locate it.
Worked Example: Checking a Continuous Conditional Distribution
Suppose five observed values have the same fitted conditional model \(X\mid H\sim N(10,4)\). The fitted mean is 10 and the fitted standard deviation is \(\sqrt{4}=2\). The observations are \(8,9,10,11,12\).
The standardized residuals are \((X-10)/2\), giving \(-1,-0.5,0,0.5,1\). Under the fitted model, the corresponding PIT values are approximately \(\Phi(-1)=0.159,\ \Phi(-0.5)=0.309,\ 0.500,\ 0.691,\ 0.841\). They are ordered and broadly span the unit interval, but five observations cannot establish uniformity.
A nominal 80% central normal prediction interval is \(10\pm 1.282(2)\), or approximately \([7.436,12.564]\). All five observations fall inside, giving empirical coverage \(5/5=100\%\). This is not decisive evidence of overcoverage: with only five observations, the empirical proportion is highly variable. In a larger sample, repeated coverage above 80%, especially within history strata, would be evidence to investigate.
Observed Versus Simulated Summaries
A complementary check compares observed summaries with predictions or trajectories generated from fitted models. For a one-step check, retain each person’s observed history \(H_t\), calculate the fitted conditional distribution at that history, and compare observed summaries with their model-based expectations. This isolates a conditional model from errors that might accumulate when earlier variables are also simulated.
For a trajectory check, simulate sequentially from fitted covariate and outcome models, using the observed baseline distribution and a clearly specified treatment process or treatment sequence. Compare summaries such as time-specific covariate prevalence, outcome risk, means, quantiles, and selected joint-history frequencies. If Monte Carlo simulation is used, simulation variability must be distinguished from discrepancies between data and model predictions.
Worked Example: Locating a Longitudinal Transition Discrepancy
In 100 people, the fitted first-transition model assigns probability \(0.38\) to \(L_1=1\). Among those with observed \(L_1=1\), the fitted probability of \(L_2=1\) is \(0.70\); among those with \(L_1=0\), it is \(0.20\). The observed counts for \((L_1,L_2)=(1,1),(1,0),(0,1),(0,0)\) are \(28,12,13,47\).
Sequential simulation gives expected cell counts \(100(0.38)(0.70)=26.6\), \(100(0.38)(0.30)=11.4\), \(100(0.62)(0.20)=12.4\), and \(100(0.62)(0.80)=49.6\). These add to 100. The simulated marginal prevalence of \(L_2=1\) is \((26.6+12.4)/100=0.39\), compared with the observed \((28+13)/100=0.41\).
To separate the transition fits, use the observed \(L_1\) groups for a one-step check of \(L_2\). Its expected number of successes is \(40(0.70)+60(0.20)=28+12=40\), compared with 41 observed. The \(L_2\) conditional discrepancy is only one event, while the first transition predicts 38 \(L_1=1\) observations and 40 are observed. The joint trajectory comparison therefore draws attention to the first transition as well as showing why a sequential simulation alone can blend errors across times.
Diagnostics in Practice: Interpretation and Failure Modes
No single diagnostic is a pass-or-fail test. Use plots and summaries that target different features, and report the scale of the comparison. For example, compare observed and predicted means by time and by substantively important history groups; check calibration for binary transitions and outcomes; and examine continuous-model residual spread, tails, and interval coverage. When observations from the same person contribute at multiple times, do not treat all residuals as independent evidence. Subject-level clustering and parameter estimation affect uncertainty around summaries.
| Approach | What it checks well | Main limitation |
|---|---|---|
| Residual plots and calibration | Systematic conditional errors and miscalibration | Limited power in sparse history groups |
| Distributional checks such as PIT and interval coverage | Shape, spread, and tail behavior | Can look adequate marginally while failing conditionally |
| Observed-versus-simulated summaries | Whether fitted transitions reproduce selected trajectories | Multiple model errors can accumulate or offset |
A frequent mistake is to declare a model adequate because its residuals average to zero. The mean-zero result concerns residuals conditional on the full history under the true conditional mean. A marginal average near zero can conceal opposite errors in subgroups; it says nothing by itself about variance, tails, or time dependence. Another mistake is to interpret successful observed-data prediction as proof that counterfactual predictions are reliable. Under an intervention, simulated histories may differ from those common in the observed data, so a model can be asked to extrapolate beyond the support on which these diagnostics provide evidence.
When diagnostics flag a concern, first identify which variable, time, and history region are involved. Residual trends may suggest a functional-form issue; poor binary calibration may indicate probability errors; poor PIT or interval coverage may reveal distributional misspecification. Sparse data can make any of these checks inconclusive. Diagnostics are evidence about fit, not a mechanical rule for choosing a model, and they cannot verify untestable causal assumptions.
Check Your Understanding
Answer each question, then compare with the solutions below.
- What does a zero overall mean of fitted binary residuals fail to rule out?
- Under what condition is the conditional PIT uniform?
- A continuous model’s nominal 90% intervals cover 70% of observed values. Name two useful follow-up checks.
- Why can a sequential simulated-versus-observed discrepancy fail to identify which transition model is responsible?
Solutions. (1) It does not rule out subgroup-specific underprediction and overprediction that cancel, nor errors in variance or distributional shape. (2) The conditional CDF must be the true continuous conditional distribution of the observation given its history; then the PIT is uniform conditional on history. (3) Check coverage by time and relevant history strata, and examine standardized residuals or PIT values for spread and tail departures. (4) A later simulated variable depends on earlier simulated variables, so an error in an early transition changes the histories on which later models are evaluated; discrepancies can accumulate or offset. A one-step check conditional on observed histories helps localize the fit problem.