Why Check the Shape of a Continuous Predictor?
A treatment model can include the right covariate and still represent its relationship with treatment poorly. For example, a logistic model that enters age only as a linear term assumes that a one-year increase has the same effect on the log odds of treatment at every age. The true relationship may instead flatten, accelerate, or change curvature. In a marginal structural model, such misspecification can distort inverse-probability weights and leave important covariate features imbalanced in the weighted data.
The practical question is not whether a flexible model fits the observed treatment indicators better in isolation. It is whether plausible representations give credible predicted treatment probabilities across the covariate range and whether their resulting weights achieve relevant balance. The earlier material on functional-form diagnostics and calibration plots provides the general diagnostic context; here the focus is how to check nonlinearity in a continuous predictor.
For example, a logistic model with one linear term has \(q(x)=\operatorname{expit}(\alpha+\beta x)\), where \(\operatorname{expit}(u)=1/(1+\exp(-u))\). A transformed model might use \(\operatorname{expit}(\alpha+\beta\log x)\), requiring \(x>0\). A spline model can use \(\operatorname{expit}\{\alpha+\sum_{j=1}^J\beta_j B_j(x)\}\), where the \(B_j\) are specified spline basis functions. In each case the model produces probabilities between zero and one, but the shapes it can express differ.
These checks assume that treatment and \(X\) are measured adequately, that the model is being used within the intended treatment decision, and that there is sufficient treatment overlap over the covariate range of interest. A flexible curve cannot repair a region with essentially no treated or untreated observations. The earlier material on positivity and extrapolation signals is especially relevant in such regions.
What Calibration Can Reveal
Calibration asks whether predicted probabilities agree with observed treatment frequencies. A useful plot places predicted probabilities on one axis and observed treatment proportions on the other, often summarizing observations within bins or using a smooth calibration curve. If the model captures the treatment mechanism adequately, observed proportions should, within sampling variability, track predictions across the range of \(X\), not merely agree on average.
Worked Example: Comparing Log and Raw-Scale Predictions
Suppose \(X\) is positive, and a fitted log-scale model is \(q_{\log}(x)=\operatorname{expit}(-2+\log x)\). At \(x=1,4,16\), suppose the observed treatment proportions in corresponding groups are \(0.12,0.35,0.70\). Compare this model with a fitted raw-\(X\) model whose predictions at those points are \(0.293,0.373,0.685\).
For the log-scale model, the linear predictors are \(-2+\log(1)=-2\), \(-2+\log(4)\approx-0.6137\), and \(-2+\log(16)\approx0.7726\). Applying the expit function gives predictions of approximately \(0.1192,0.3512,0.6841\), respectively.
The log-scale absolute discrepancies are \(|0.12-0.1192|=0.0008\), \(|0.35-0.3512|=0.0012\), and \(|0.70-0.6841|=0.0159\). The raw-scale discrepancies are \(|0.12-0.293|=0.173\), \(|0.35-0.373|=0.023\), and \(|0.70-0.685|=0.015\). Thus the log-scale model is much closer at \(x=1\) and \(x=4\), while the raw-scale model is slightly closer at \(x=16\). The pattern suggests checking the shape more closely; it does not establish which model is correct, since group proportions are noisy and the predictions are evaluated at only three points.
Calibration summaries can conceal local errors. A model may predict too low in one part of the range and too high in another, with the errors canceling overall. Inspect the calibration pattern across \(X\), including its tails, and report how observations are distributed there. Bins with few observations yield unstable observed proportions; a smooth curve can also look reassuring while being driven by sparse regions. Calibration is a diagnostic, not a proof of correct specification.
Why Post-Weighting Balance Tests the Shape
Calibration checks predictions against observed treatment frequencies. Balance checks the practical consequence of those predictions: whether weighting makes the measured covariates comparable across treatment groups. To see the connection, consider a binary treatment with true propensity \(e(X)=P(A=1\mid X)\), assume \(0<e(X)<1\) almost surely, and use unstabilized inverse-probability weights \(A/e(X)\) for treated observations.
Proof. By iterated expectation, conditioning on \(X\), \(E[A\mid X]=e(X)\). Therefore
Taking \(h(X)=1\) gives \(E[A/e(X)]=E[1]=1\). Dividing the first equality by the second shows that the normalized weighted treated mean of \(h(X)\) equals \(E[h(X)]\). For controls, \(E[1-A\mid X]=1-e(X)\), so the same argument gives \(E[(1-A)h(X)/(1-e(X))]=E[h(X)]\) and \(E[(1-A)/(1-e(X))]=1\). Integrability ensures that the expectations used here are defined. \(\square\)
In a sample, these equalities motivate checking weighted means of \(X\), but a mean check alone is limited: it says nothing directly about \(X^2\), a nonlinear transformation, or the overall distribution. If the fitted probability is \(q(X)\) rather than the true \(e(X)\), the treated weighted expectation has numerator \(E[e(X)h(X)/q(X)]\) and denominator \(E[e(X)/q(X)]\). Their ratio need not equal \(E[h(X)]\). Nonlinear imbalance after weighting can therefore be evidence that a fitted functional form deserves scrutiny.
Worked Example: Mean Balance Can Miss Curvature
Suppose normalized post-weighting distributions of \(X\) have the following masses on the common support \(\{-2,-1,1,2\}\). The treated weighted distribution assigns mass \(0.30\) to each of \(-2,2\) and \(0.20\) to each of \(-1,1\). The control weighted distribution assigns mass \(0.10\) to each of \(-2,2\) and \(0.40\) to each of \(-1,1\). Each set of masses sums to one.
Both weighted means are zero by symmetry. For the treated group, \(E_w[X]=0.30(-2)+0.20(-1)+0.20(1)+0.30(2)=0\). For controls, \(E_w[X]=0.10(-2)+0.40(-1)+0.40(1)+0.10(2)=0\). A diagnostic checking only the mean of \(X\) would therefore report exact balance.
The second moments differ. For treated observations, \(E_w[X^2]=0.60(4)+0.40(1)=2.8\); for controls, \(E_w[X^2]=0.20(4)+0.80(1)=1.6\). The difference is \(2.8-1.6=1.2\). Thus the weighted distributions agree in their means but not in a nonlinear feature of \(X\). Checking transformed terms, higher moments, or distributional balance can uncover what a mean check misses.
Choosing and Comparing Representations
A linear term is economical and often stable, but it restricts the log odds to a straight line in \(X\). A transformation such as \(\log(X)\) can express a relationship that changes more rapidly at low values and more gradually at high values, but it requires a meaningful domain and a defensible choice of transformation. A spline can represent gradual curvature without choosing one global transformation, but it introduces additional parameters and can become unstable where data are sparse. Knot locations, boundary behavior, and the amount of smoothing matter.
Use a common diagnostic sequence for each plausible representation: examine predicted probabilities across the observed range; inspect calibration by ranges of \(X\); calculate weights under the model; and assess balance not only for \(X\) but also for scientifically relevant functions or distributional features. The earlier material on standardized differences, higher-moment balance, and empirical CDFs gives complementary ways to summarize these checks. These measures are not interchangeable: a small difference in means does not guarantee similar distributions.
Worked Example: Reading a Piecewise-Linear Spline
For a predictor measured on a scale where \(X=1\) is a meaningful knot, consider the fitted model \(q(x)=\operatorname{expit}\{-2+0.8x+0.5(x-1)_+\}\), where \((x-1)_+=\max(x-1,0)\). Calculate predictions at \(x=0,1,2\) and interpret the change in slope.
At \(x=0\), the hinge term is zero, so the linear predictor is \(-2\) and \(q(0)=\operatorname{expit}(-2)\approx0.1192\). At \(x=1\), the hinge term remains zero, giving linear predictor \(-2+0.8=-1.2\) and \(q(1)\approx0.2315\). At \(x=2\), the hinge term is \(1\), giving linear predictor \(-2+1.6+0.5=0.1\) and \(q(2)\approx0.5250\).
Below the knot, the log-odds slope is \(0.8\); above it, the slope is \(0.8+0.5=1.3\). The spline permits the treatment log odds to rise more quickly above \(x=1\). The three predictions show how that flexibility changes estimated probabilities, but they do not validate the knot or model. Calibration and weighted balance still need to be inspected, particularly near the predictor's boundaries.
Limitations and Common Pitfalls
A frequent mistake is to choose the model with the most flexible curve because it appears to follow every fluctuation in observed treatment proportions. The correction is to distinguish signal from sampling noise: sparse bins can fluctuate substantially, and extra spline parameters can create extreme predicted probabilities and weights. Examine the number of observations and treatment events across \(X\), consider whether predicted probabilities approach zero or one, and interpret balance changes alongside overlap. A visually smooth curve is not evidence of reliable estimation in regions with little information.
A second mistake is to treat good overall calibration as proof that the treatment model is correct. For instance, let \(X\) take values \(0\) and \(1\) with equal probability and let the true treatment probabilities be \(0.2\) and \(0.8\), respectively. The overall treatment probability is \((0.2+0.8)/2=0.5\). A model predicting \(0.5\) for everyone is calibrated overall, yet its conditional predictions are wrong by \(0.3\) at each value of \(X\). Calibration must be examined across the covariate range, and weighted balance must also be assessed.
No single diagnostic establishes causal identification or guarantees an unbiased marginal structural model estimate. These checks address measured covariate representation in the treatment model; they cannot diagnose unmeasured confounding, measurement error, or every form of misspecification. The most informative approach is a transparent sensitivity analysis across defensible linear, transformed, and spline specifications, with attention to predictions, weights, overlap, and balance.
Check Your Understanding
Answer each question, then compare your reasoning with the solutions.
- Why can a logistic model with a linear term for \(X\) be nonlinear in probability while still being restrictive in its representation of \(X\)?
- If weighted means of \(X\) match but weighted means of \(X^2\) differ, what does that suggest about the balance assessment?
- For \(e(X)=P(A=1\mid X)\), state the positivity condition needed for the treated inverse-probability weight \(A/e(X)\) to be defined.
- Why does calibration of predicted probabilities averaged over the whole sample not establish calibration across \(X\)?
Solutions. (1) The expit link maps a linear predictor to a curved probability scale, but the log odds are constrained to be a straight line in \(X\); the model cannot express arbitrary curvature in the log odds. (2) Mean balance is insufficient: the groups differ in a nonlinear feature, so check additional functions or distributional summaries of \(X\). (3) Require \(e(X)>0\) almost surely for treated weights to be defined; for both treatment groups to be represented, require \(0<e(X)<1\) over the target covariate support. (4) Errors at different covariate values can cancel in the aggregate, as the probabilities \(0.2\) and \(0.8\) average to \(0.5\); calibration should be examined across the range.