Why Functional Form Needs Its Own Diagnostics
A treatment model can rank people well and still describe the effect of a continuous covariate poorly. For example, a model with a straight-line effect of age on the log odds of treatment may predict probabilities that are systematically too high in one age range and too low in another. A single overall fit summary can obscure that pattern. In a marginal structural model (MSM), such errors matter because estimated treatment probabilities determine the weights used to create a pseudo-population.
The target here is the functional form for a continuous covariate, not the full set of model choices. Residual patterns, calibration within covariate ranges, and post-weighting balance provide complementary evidence. None proves that a treatment model is correct: these are diagnostics, and their interpretation depends on support, sample size, and the history included in the model.
For an interpretable diagnostic, the fitted probability should be evaluated on the same treatment occasion and history as the observed \(A_t\). The model must at least use a well-defined pre-treatment history, and the probabilities used in inverse-probability weights must be positive for the treatment choices represented in the target population. If the histories have little support in a region of \(X_t\), apparent patterns there can reflect sparse data or extrapolation rather than a clearly identified shape error.
Residual Patterns and Their Direction
A positive residual means the observed treatment was 1 while the fitted probability was below 1, or that the model assigned a probability smaller than the observed treatment indicator. Averaging residuals over many observations makes the comparison more useful: within a covariate range, the average residual is the observed treatment proportion minus the average fitted probability. A positive average therefore signals underprediction in that range; a negative average signals overprediction.
A plot of residuals against \(X_t\), or a smooth of their conditional average, can reveal a trend or curvature that a single average conceals. For a correctly specified conditional probability, the population residual has mean zero conditional on the full history. In practice, a binned or smoothed residual plot is a noisy, lower-dimensional check: it asks whether the model has systematic errors associated with the continuous covariate, not whether every detail of the conditional model is correct.
Worked Example: Reading Residual Signs Across a Covariate
Suppose a fitted model is assessed in two equally sized ranges of a continuous covariate. In the low range, 12 of 40 people receive treatment, while the fitted probabilities average 0.20. In the high range, 24 of 40 receive treatment, while fitted probabilities average 0.70. Calculate and interpret the average residual in each range.
In the low range, the observed treatment proportion is \(12/40=0.30\), so the average residual is \(0.30-0.20=0.10\). The model underpredicts treatment there by 0.10 on average.
In the high range, the observed proportion is \(24/40=0.60\), so the average residual is \(0.60-0.70=-0.10\). The model overpredicts treatment there by 0.10 on average.
The two ranges have equal size, so their residual averages cancel: \((0.10+(-0.10))/2=0\). That overall average does not remove the opposing covariate-specific errors. The signs indicate a pattern worth investigating, but finite-sample variation or limited support could also produce it.
Calibration Within Covariate Ranges
Calibration compares observed treatment frequencies with fitted probabilities. Overall calibration checks whether the average observed treatment frequency is close to the average predicted probability. For functional form, the more revealing comparison is often made within ranges of \(X_t\), or using a smooth calibration curve against \(X_t\). A model can match the overall frequency while missing the way treatment probability changes across the covariate.
To verify this identity, condition first on the full history. Because \(E[A_t\mid H_t]=q_t(H_t)\) and \(\hat q_t(H_t)\) is determined by that history, $$ E[R_t\mid H_t]=E[A_t-\hat q_t(H_t)\mid H_t]=q_t(H_t)-\hat q_t(H_t). $$ Taking conditional expectations of both sides given \(B\), and using that \(B\) is determined by \(H_t\), gives the result. In data, the group mean residual estimates the left side; it is not the unknown true discrepancy itself. \(\square\)
Worked Example: Overall Calibration Can Hide Range-Specific Errors
Consider two equally sized covariate ranges. In the low range the observed treatment proportion is 0.30 and the mean fitted probability is 0.40. In the high range the observed proportion is 0.70 and the mean fitted probability is 0.60. Compare the overall and range-specific calibration.
The overall observed proportion is \((0.30+0.70)/2=0.50\). The overall mean fitted probability is also \((0.40+0.60)/2=0.50\). Thus the model is calibrated overall.
Within the low range, observed minus predicted is \(0.30-0.40=-0.10\), so treatment is overpredicted. Within the high range, the difference is \(0.70-0.60=0.10\), so treatment is underpredicted. The errors cancel overall, but the covariate-specific calibration is poor. A useful diagnostic should therefore report group counts and uncertainty as well as group averages; very small groups can yield unstable proportions.
Weighted Balance as a Functional-Form Check
Another diagnostic asks whether weighting by the fitted treatment probabilities makes covariates comparable across treatment groups. For one treatment occasion, define the unstabilized inverse-probability weights \(A_t/\hat q_t(H_t)\) for treated observations and \((1-A_t)/(1-\hat q_t(H_t))\) for untreated observations. If the true probability \(q_t(H_t)\) is used, weighting balances any integrable function of the pre-treatment history in expectation.
For the treated identity, condition on \(H_t\). Since \(h(X_t)\) and \(q_t(H_t)\) are determined by \(H_t\), $$ E\left[\left.\frac{A_t h(X_t)}{q_t(H_t)}\right|H_t\right] =\frac{h(X_t)}{q_t(H_t)}E[A_t\mid H_t] =h(X_t). $$ Taking expectations gives the first equality. For the untreated identity, \(E[1-A_t\mid H_t]=1-q_t(H_t)\), so $$ E\left[\left.\frac{(1-A_t)h(X_t)}{1-q_t(H_t)}\right|H_t\right] =\frac{h(X_t)}{1-q_t(H_t)}(1-q_t(H_t)) =h(X_t). $$ Taking expectations gives the second equality. The integrability condition ensures that these expectations exist. \(\square\)
With fitted probabilities, substantial imbalance in \(X_t\) or in functions of \(X_t\) can be evidence that the model's covariate effect is inadequate. A balance check should not stop at the mean: \(h(X_t)=X_t\) checks the mean, while choices such as \(X_t^2\) or indicators for covariate ranges probe other features. This is a diagnostic principle, not a guarantee that all relevant confounding has been controlled.
Worked Example: Comparing Weighted Means Under Two Fits
For four observations, let \(X=( -1,0,1,2)\) and \(A=(1,0,1,0)\). Candidate model A assigns probabilities \((0.20,0.40,0.60,0.80)\); candidate model B assigns \((0.40,0.30,0.70,0.60)\). Compute the weighted mean of \(X\) in each treatment group for both candidates, using the unstabilized weights.
Under candidate A, the treated weights are \(1/0.20=5\) at \(X=-1\) and \(1/0.60=1.6667\) at \(X=1\). Their weighted mean is $$ \frac{5(-1)+1.6667(1)}{5+1.6667} =\frac{-3.3333}{6.6667}=-0.5000. $$ The untreated weights are \(1/(1-0.40)=1.6667\) at \(X=0\) and \(1/(1-0.80)=5\) at \(X=2\). Their weighted mean is \(10/6.6667=1.5000\). The absolute difference is \(2.0000\).
Under candidate B, the treated weights are \(1/0.40=2.5\) and \(1/0.70=1.4286\). The treated weighted mean is $$ \frac{2.5(-1)+1.4286(1)}{2.5+1.4286} =\frac{-1.0714}{3.9286}\approx -0.2727. $$ The untreated weights are \(1/(1-0.30)=1.4286\) at \(X=0\) and \(1/(1-0.60)=2.5\) at \(X=2\). Their weighted mean is \(5/3.9286\approx1.2727\), giving an absolute difference of \(17/11\approx1.5455\).
Candidate B reduces this particular weighted mean difference, but the four-observation calculation is extremely unstable and cannot establish that B is correctly specified. A serious comparison uses the full sample, reports uncertainty and weight behavior, and examines more than one balance feature.
Choosing and Comparing Functional Forms
A practical comparison might begin with a linear term for \(X_t\) in the treatment model and then consider a scientifically plausible alternative, such as a quadratic term or a prespecified transformation. Each candidate should be judged using the same target population and treatment history. Compare residual or calibration patterns across \(X_t\), and inspect weighted balance for \(X_t\) and relevant functions of it. A small improvement in likelihood or discrimination alone does not demonstrate improved balance.
Diagnostics are most informative when the covariate has enough observations across its range. Displaying range-specific sample sizes, treatment counts, and uncertainty helps distinguish a persistent pattern from noise. Extreme fitted probabilities also deserve attention: they can create unstable weights, so a model that appears to improve balance by assigning extreme probabilities may worsen the reliability of the weighted analysis.
No single diagnostic dominates. Residual plots and calibration examine probability errors directly; weighted balance examines a consequence of those errors for the weighted pseudo-population. Flexible forms can reduce visible discrepancies, but they may overfit sparse regions. A model should not be chosen solely because it makes one balance statistic look favorable, and passing these checks does not establish exchangeability, positivity, or correct specification of every covariate effect.
Common Pitfalls and Limitations
- Reversing residual signs. Since \(R_t=A_t-\hat q_t(H_t)\), a positive group average means underprediction, while a negative average means overprediction.
- Relying on the overall average. Opposing errors across covariate ranges can cancel, leaving an overall residual mean near zero.
- Treating balance as proof. A small difference in the weighted mean of \(X_t\) does not guarantee balance in its distribution, in other history variables, or in unmeasured confounders.
- Overinterpreting noisy curves. Sparse support and random variation can produce apparent bends. Conversely, in-sample fitting can make residual summaries look reassuring, especially when model fitting directly targets related averages.
- Confusing fit with the causal target. A better-fitting treatment model is not automatically a better causal analysis; probabilities must be appropriate for the weighting estimand and the observed history.
These diagnostics flag reasons to investigate and compare specifications; they do not select a unique true model from data. If plausible forms lead to meaningfully different weighting behavior, report that sensitivity rather than hiding it behind one preferred fit.
Check Your Understanding
Answer each question, then compare with the brief solutions.
- In a covariate range, the observed treatment proportion is 0.25 and the mean fitted probability is 0.35. What is the mean residual, and what does its sign indicate?
- Why can an overall calibration comparison miss functional-form error across a continuous covariate?
- Under the theorem's assumptions, what does inverse-probability weighting imply for the expectation of an integrable \(h(X_t)\) in the untreated group?
- A residual plot has positive averages at low \(X_t\) and negative averages at high \(X_t\). State the corresponding possible prediction pattern, and give one reason not to treat it as conclusive evidence.
- Why is a reduction in weighted mean difference alone insufficient to establish that an alternative treatment model is adequate?
Solutions. (1) The mean residual is \(0.25-0.35=-0.10\), indicating average overprediction. (2) Errors in different ranges can cancel in the overall average. (3) \(E[(1-A_t)h(X_t)/(1-q_t(H_t))]=E[h(X_t)]\), provided positivity and integrability hold. (4) The model may underpredict treatment at low \(X_t\) and overpredict it at high \(X_t\), because residuals are observed minus fitted treatment probabilities. Sampling variation or sparse support could also produce the pattern, so it is not proof of misspecification. (5) Mean balance checks only one feature; other distributional imbalances, instability, or misspecification in other covariates may remain.