Tutorials › Marginal Structural Models › Covariate Balance After Weighting in a Diabetes Cohort

Case Studies · Tutorial 496 of 501

Covariate Balance After Weighting in a Diabetes Cohort

Use weighted summaries and longitudinal diagnostics to evaluate measured covariate balance while recognizing what balance cannot establish about causal validity.

Advanced 12 min read

What You'll Learn

  • Define weighted means, variances, and signed standardized mean differences for treatment comparisons.
  • Evaluate time-varying HbA1c and renal-function balance at successive treatment decisions.
  • Derive the balance identity for inverse-probability weighting and its stabilized-weight counterpart.
  • Use distributional diagnostics, weight summaries, and effective sample size to detect problems.
  • Explain why improved measured balance does not establish exchangeability or causal validity.
  • Compare weighting diagnostics with matching and outcome-model approaches.

Why Balance Is a Diagnostic, Not a Verdict

In a diabetes cohort, treatment decisions may respond to recent glycemic control and renal function. A patient with rising HbA1c or declining estimated glomerular filtration rate (eGFR) may be more likely to start or intensify a particular therapy. Those histories can also predict later outcomes. In a marginal structural analysis, weighting aims to create a pseudo-population in which measured treatment predictors are balanced across treatment choices at each decision time.

Balance assessment asks whether the observed covariate histories are more alike after weighting. It does not establish that all confounding has been removed, that the weights are correctly modeled, or that a causal effect is identified. It is one important diagnostic alongside the design assumptions and the outcome analysis.

What to Compare at Each Decision Time

Let \(A_t\) denote treatment at time \(t\), and let \(L_t\) contain covariates measured by that time, including HbA1c and renal function. Write \(H_t=(L_0,A_0,L_1,\ldots,A_{t-1},L_t)\) for the observed history just before \(A_t\). A treatment decision can depend on several aspects of that history: the current HbA1c and eGFR, their earlier levels, and their recent changes.

Definition: Weighted balance at decision time \(t\) is similarity in the measured history \(H_t\) across values of \(A_t\), evaluated using the analysis weights. With stabilized weights, the relevant comparison is generally within strata of past treatment history \(\bar A_{t-1}\), because the numerator of the weights can retain associations with past treatment.

For binary treatment, let \(w_i\) be the analysis weight for person \(i\) at the decision being assessed. In treatment group \(a\), the weighted mean of a covariate \(X\) is

$$ \bar X_{a,w}= \frac{\sum_{i:A_i=a}w_iX_i}{\sum_{i:A_i=a}w_i}. $$

The corresponding weighted variance uses the same normalized weights:

$$ s^2_{a,w}= \frac{\sum_{i:A_i=a}w_i(X_i-\bar X_{a,w})^2} {\sum_{i:A_i=a}w_i}. $$

A signed standardized mean difference (SMD), defined here as group 1 minus group 0, is

$$ \operatorname{SMD}_w(X)= \frac{\bar X_{1,w}-\bar X_{0,w}} {\sqrt{(s^2_{1,w}+s^2_{0,w})/2}}. $$

The sign indicates the direction of the difference; its absolute value describes its size in pooled standard-deviation units. For categorical covariates, compare weighted proportions for each category. For a longitudinal history, assess more than one current-time mean: include prior measurements, changes or slopes, and clinically meaningful nonlinear transformations or interactions.

Worked Example: Rechecking a Signed Weighted SMD

Suppose the weighted HbA1c means are 8.5% in treatment group 1 and 9.5% in group 0. Both groups have weighted variances of 0.75. Calculate the signed SMD using the stated group-1-minus-group-0 convention.

The numerator is \(8.5-9.5=-1.0\). The pooled standard deviation is \(\sqrt{(0.75+0.75)/2}=\sqrt{0.75}\approx0.866\). Therefore,

$$ \operatorname{SMD}_w= \frac{8.5-9.5}{\sqrt{0.75}} =\frac{-1}{\sqrt{0.75}} \approx -1.155. $$

The negative sign is essential under this definition: group 1 has the lower weighted mean. The absolute SMD is \(1.155\). Reporting \(+1.155\) as the signed SMD would reverse the direction, even though its absolute magnitude would be correct.

Why Inverse-Probability Weights Balance Measured Histories

The population identity below explains the diagnostic target. Let \(p_t(a\mid H_t)=P(A_t=a\mid H_t)\). For this result, use the unstabilized treatment weight \(W_t=W_{t-1}/p_t(A_t\mid H_t)\), where \(W_{t-1}\) is nonnegative and measurable with respect to \(H_t\). Assume treatment has a finite number of categories, \(p_t(a\mid H_t)>0\) on the histories considered, and \(0<E[W_{t-1}]<\infty\).

Theorem: For any measurable \(g(H_t)\) satisfying \(E[W_{t-1}|g(H_t)|]<\infty\), and any treatment category \(a\),
$$ E[W_tg(H_t)I(A_t=a)]=E[W_{t-1}g(H_t)]. $$

Proof. Conditional on \(H_t\), the probability of \(A_t=a\) is \(p_t(a\mid H_t)\), and on that event \(W_t=W_{t-1}/p_t(a\mid H_t)\). Thus,

$$ \begin{aligned} E[W_tg(H_t)I(A_t=a)\mid H_t] &=\frac{W_{t-1}g(H_t)}{p_t(a\mid H_t)} E[I(A_t=a)\mid H_t]\\ &=W_{t-1}g(H_t). \end{aligned} $$

The stated integrability condition makes the right-hand side integrable and the equality of finite expectations valid. Taking expectations proves the identity. In particular, setting \(g=1\) shows that every treatment category has the same weighted mass, \(E[W_{t-1}]\). Dividing the identity by this mass shows that the weighted distribution of \(H_t\) within each category has the same expectations for all such \(g\). Taking \(g\) to be indicators of measurable history sets gives equality of those weighted distributions. \(\square\)

This is a population result under the true treatment probabilities. In data, probabilities are estimated, weights are finite-sample quantities, and exact equality is not guaranteed. Residual imbalance can therefore be informative about finite-sample variability, limited overlap, or how the weighting procedure behaves.

What Stabilization Changes

A stabilized weight replaces the numerator 1 with a treatment probability depending on past treatment. Write \(q_t(a\mid\bar A_{t-1})\) for this numerator probability and define \(W_t^s=W_{t-1}^s q_t(A_t\mid\bar A_{t-1})/p_t(A_t\mid H_t)\). The comparison it motivates is conditional on a fixed past treatment history.

Result: Fix a past treatment history \(\bar A_{t-1}=b\), and suppose the relevant numerator probabilities are positive. If \(E[W_{t-1}^s|g(H_t)|I(\bar A_{t-1}=b)]<\infty\), then
$$ E[W_t^sg(H_t)I(A_t=a,\bar A_{t-1}=b)] =q_t(a\mid b)E[W_{t-1}^sg(H_t)I(\bar A_{t-1}=b)]. $$

Derivation. Conditional on \(H_t\), the numerator \(q_t(a\mid b)\) is fixed on the event \(\bar A_{t-1}=b\). The conditional expectation of \(I(A_t=a)/p_t(a\mid H_t)\) is 1. Multiplying by the past weight and \(q_t(a\mid b)\), then taking expectations, gives the displayed identity. Taking \(g=1\) gives the weighted mass in that treatment-history stratum. Dividing the identity by that mass shows that the normalized weighted history distribution is the same across current treatment categories within the stratum. The integrability condition ensures these expectations are finite. \(\square\)

The numerator factor can make marginal comparisons across different past treatment histories look different, by design. Consequently, a diagnostic should state whether it compares current treatment groups within past-treatment strata or reports a marginal summary across those strata. The former more directly checks balance at the current decision.

Worked Example: Balance Before and After Weighting

At one decision time, four patients have HbA1c values 7 and 9 in treatment group 1, and 8 and 10 in group 0. Initially all weights equal 1. After weighting, group 1 has weights 1 and 3 on values 7 and 9; group 0 has weights 3 and 1 on values 8 and 10. Calculate the weighted means and SMD.

Before weighting, the means are \((7+9)/2=8\) and \((8+10)/2=9\). Each group has variance 1, so the unweighted SMD is \((8-9)/\sqrt{1}=-1\).

After weighting, group 1 has mean \((1\cdot7+3\cdot9)/4=34/4=8.5\); group 0 has mean \((3\cdot8+1\cdot10)/4=34/4=8.5\). For group 1, the variance is \([1(7-8.5)^2+3(9-8.5)^2]/4=(2.25+0.75)/4=0.75\). For group 0, it is \([3(8-8.5)^2+1(10-8.5)^2]/4=(0.75+2.25)/4=0.75\). Hence the weighted SMD is \((8.5-8.5)/\sqrt{0.75}=0\). In this small illustration, weighting removes the mean difference in this measured covariate. That result alone says nothing about unmeasured histories or causal assumptions.

Worked Example: Assessing HbA1c and Renal History Over Time

Suppose the scientific comparison concerns two diabetes treatment strategies over three decisions, \(t=0,1,2\). At \(t=1\), within each past-treatment stratum, calculate weighted summaries for current HbA1c, prior HbA1c, eGFR, and the change in eGFR since baseline. At \(t=2\), repeat these comparisons using the histories available just before that decision.

For illustration, in one \(t=1\) stratum the weighted HbA1c mean is 8.1% for current treatment 1 and 8.3% for current treatment 0, with pooled standard deviation 1.0. Its SMD is \((8.1-8.3)/1.0=-0.20\). If weighted eGFR means are 58 and 62, and the pooled standard deviation is 10, the eGFR SMD is \((58-62)/10=-0.40\). The latter shows a larger remaining standardized difference: group 1 has lower eGFR.

These two calculations do not summarize the whole history. If prior HbA1c or eGFR slope remains markedly different, current means can conceal imbalance in the trajectory. A complete diagnostic table should therefore include those variables as well as weighted category proportions for factors such as insulin use or renal-disease stage. It should report the comparison stratum, weight definition, and direction convention so that results can be interpreted consistently.

Diagnostics, Alternatives, and Limitations

A useful assessment considers the full pattern, not a single cutoff. Inspect balance before and after weighting at every decision time; summarize current and lagged HbA1c and eGFR, clinically relevant transformations, and categorical predictors. Weighted empirical distributions or plots can reveal differences in spread, skewness, or tails even when means agree. Also inspect the weight distribution and effective sample size,

$$ \operatorname{ESS}=\frac{(\sum_i w_i)^2}{\sum_i w_i^2}. $$

For equal weights, ESS equals the number of observations. Concentration in a few large weights reduces it, so apparently close weighted means may be unstable. Check that each treatment-history stratum has adequate representation and report how any truncation changes both weights and balance; truncation can reduce extreme weights while reintroducing imbalance.

Balance is not a test of the treatment model and there is no universal SMD threshold that guarantees validity. Good measured balance can coexist with unmeasured confounding, measurement error, or incorrect time ordering. Poor balance can flag inadequate overlap, model limitations, or finite-sample instability, but a diagnostic alone does not identify which cause is responsible. The causal interpretation additionally relies on consistency, sequential exchangeability conditional on the measured histories, positivity, and appropriate handling of loss to follow-up when relevant.

Matching can target similarity among selected individuals but may discard observations and does not automatically address changing treatment and confounder histories. Outcome regression instead models the outcome conditional on covariates; it can adjust measured differences under a suitable model but does not itself create a weighted balanced population. Weighting is useful for marginal contrasts, but balance diagnostics should be read with the estimand and assumptions in view, not as a certificate of causal validity.

Common Pitfalls

  • Reporting only current covariate means. Similar current HbA1c does not imply similar prior HbA1c or eGFR trajectories. Add lagged values and relevant history summaries.
  • Ignoring the sign convention. If SMD is group 1 minus group 0, keep that order in the numerator. Taking an absolute value is valid only when explicitly reporting an absolute SMD.
  • Using ordinary integrability for weighted identities. For the finite-expectation identity above, require \(E[W_{t-1}|g(H_t)|]<\infty\); integrability of \(g\) alone does not ensure weighted expectations exist.
  • Treating good balance as proof. Balance applies to measured variables and the observed weighted sample. It cannot verify the absence of unmeasured confounding or establish positivity across unsupported treatment choices.
  • Pooling past treatment histories without explanation. Stabilized weights can retain associations with past treatment through their numerator. State whether current-treatment balance was assessed within past-treatment strata.

Check Your Understanding

Use the definitions and calculations above to answer each question.

  1. A weighted SMD is defined as group 1 minus group 0. The means are 7.2 and 7.8, and the pooled standard deviation is 1.5. What is the signed SMD?
  2. Why should a longitudinal balance table include prior eGFR or its change, rather than only eGFR at the current decision?
  3. What extra condition makes the finite-expectation weighting identity safe to use for a signed function \(g(H_t)\)?
  4. Suppose weighted HbA1c and eGFR summaries are balanced. Name one reason this does not establish causal validity.

Solutions. (1) The numerator is \(7.2-7.8=-0.6\), so the signed SMD is \(-0.6/1.5=-0.40\). (2) Current values can agree while prior levels or trajectories differ; those histories may both predict treatment and outcome. (3) Require \(E[W_{t-1}|g(H_t)|]<\infty\), along with the stated positivity and finite-weight assumptions. (4) For example, an unmeasured confounder may remain associated with treatment and outcome even when the measured variables are balanced.

Clinical Biostats