Tutorials › Propensity Score Matching and Instrumental Variables › Finding Residual Imbalance Within Feature Blocks

Time-Varying and High-Dimensional Confounding · Tutorial 635 of 699

Finding Residual Imbalance Within Feature Blocks

Use feature-level and block-level balance diagnostics together to locate residual imbalance and investigate whether it reflects coding, timing, or selection choices.

Advanced 11 min read

What You'll Learn

  • Calculate fixed-scale standardized mean differences for binary and continuous features after matching or weighting.
  • Summarize block imbalance with RMS, maximum absolute difference, and the share of features exceeding a chosen diagnostic threshold.
  • Explain why an overall balance summary can conceal a problematic diagnosis, medication, procedure, or utilization block.
  • Recompute the pre-adjustment scale when a feature’s coding or timing definition changes.
  • Trace persistent imbalance to plausible data construction or feature-selection decisions.
  • Distinguish balance diagnostics from tests of causal identification or treatment-effect validity.

Why Examine Balance by Feature Block?

A high-dimensional propensity analysis may include thousands of diagnosis, medication, procedure, and utilization features. A single overall balance summary can look acceptable while a clinically coherent group remains poorly balanced. For example, many well-balanced diagnosis indicators could dominate an average and obscure persistent imbalance in prior procedures or health-care use. Examining features within blocks makes the diagnostic question more specific: where does residual imbalance cluster, and what decision in constructing or selecting the features might explain it?

A block is an analytic grouping of features, not necessarily a biological or causal unit. It may be defined by the source or coding family—for example, diagnosis codes, medication classes, procedure codes, or measures of utilization—or by a prespecified clinical rationale. The grouping should be defined consistently and reported clearly. Block diagnostics supplement feature-level balance checks; they do not replace them or establish that confounding has been eliminated.

Definition: Residual imbalance is a difference between the treatment groups in the distribution of a measured pretreatment feature after the chosen matching or weighting procedure. A feature block is a prespecified set of related features summarized together for diagnostic purposes. Neither a small block summary nor good balance on measured features proves exchangeability or absence of unmeasured confounding.

Feature-Level Differences and Block Summaries

For feature \(j\), let \(\bar X_{1j}^{\,*}\) and \(\bar X_{0j}^{\,*}\) denote its means in the treated and comparison groups after the design procedure, using the analysis weights or matched sample. For a binary feature, a mean is its prevalence. A standardized mean difference (SMD) expresses the adjusted difference on a scale that is less dependent on the feature’s units.

A useful convention is to divide the adjusted mean difference by the feature’s pooled standard deviation in the original, pre-adjustment treatment groups. This fixed denominator keeps the scale anchored to the original cohort rather than allowing the adjustment itself to alter the yardstick. For a continuous feature, calculate that denominator from the two original group variances. For a binary feature with original prevalences \(p_{1j}^{\,pre}\) and \(p_{0j}^{\,pre}\), use the pooled Bernoulli standard deviation:

$$ SMD_j = \frac{\bar X_{1j}^{\,*}-\bar X_{0j}^{\,*}} {\sqrt{\left(s_{1j,pre}^{\,2}+s_{0j,pre}^{\,2}\right)/2}}, \qquad s_{aj,pre}^{\,2}=p_{aj}^{\,pre}(1-p_{aj}^{\,pre}) \quad\text{for a binary feature.} $$

The sign indicates which group has the larger adjusted mean; the magnitude indicates the standardized difference. For a block \(B\) containing \(m_B\) features, one summary is the root mean square of its feature-level SMDs. The RMS retains the influence of large differences and avoids cancellation between positive and negative SMDs. Because it squares the values, it does not show which feature is responsible, so report it alongside the largest absolute SMD and, where useful, the share of features whose absolute SMD exceeds a prespecified diagnostic threshold.

$$ R_B=\sqrt{\frac{1}{m_B}\sum_{j\in B} SMD_j^2}, \qquad M_B=\max_{j\in B}|SMD_j|, \qquad Q_B(c)=\frac{1}{m_B}\sum_{j\in B} I(|SMD_j|>c). $$

Here \(I(\cdot)\) is 1 when its condition is true and 0 otherwise; \(c\) is a chosen threshold used for description, not a universal pass/fail boundary. Report the number of features in each block, because a proportion based on a small block can be unstable and an RMS over many features can dilute a few important discrepancies. A table or plot of individual SMDs remains necessary to locate the feature-level pattern.

Worked Examples

Worked Example: A Diagnosis Block with Mixed Directions

Suppose a hypothetical analysis has a diagnosis block with two binary features. The first represents a prior chronic-disease diagnosis and the second a prior acute-condition diagnosis. The values below are adjusted prevalences and original-cohort prevalences. Apply the fixed pre-adjustment scale.

FeatureOriginal treated prevalenceOriginal comparison prevalenceAdjusted treated prevalenceAdjusted comparison prevalence
Chronic-disease diagnosis0.100.100.400000.26584
Acute-condition diagnosis0.200.200.140000.20064

For the chronic-disease feature, the original pooled standard deviation is \(\sqrt{[0.10(0.90)+0.10(0.90)]/2}=\sqrt{0.09}=0.3000\). Thus \(SMD_1=(0.40000-0.26584)/0.3000=0.4472\). For the acute-condition feature, the denominator is \(\sqrt{[0.20(0.80)+0.20(0.80)]/2}=\sqrt{0.16}=0.4000\); therefore \(SMD_2=(0.14000-0.20064)/0.4000=-0.1516\).

The block RMS is \(R_B=\sqrt{(0.4472^2+(-0.1516)^2)/2} =\sqrt{(0.2000+0.02298)/2} =\sqrt{0.11149}=0.3339\), using the unrounded SMDs for the final calculation. The maximum absolute SMD is \(M_B=0.4472\). The opposite signs do not cancel in the RMS, but the RMS alone also does not identify which condition drives the summary. The feature-level results show that the chronic-disease diagnosis is the larger residual difference and merits investigation.

Worked Example: Rebuilding a Feature After a Timing Audit

In a hypothetical claims analysis, an initial medication-history feature inadvertently counted claims dated during the first 30 days after treatment initiation. The team rebuilds it to include only the prespecified pretreatment lookback period. The corrected feature has original-cohort prevalences of 0.16 in the treated group and 0.09 in the comparison group; after adjustment, its prevalences are 0.12 and 0.10. Calculate the corrected SMD using the corrected feature’s original-cohort scale.

The denominator must be calculated from the corrected original-cohort prevalences: \[ \sqrt{\frac{0.16(0.84)+0.09(0.91)}{2}} =\sqrt{\frac{0.1344+0.0819}{2}} =\sqrt{0.10815} =0.3289. \] The adjusted prevalence difference is \(0.12-0.10=0.0200\). Therefore, \[ SMD=\frac{0.0200}{0.3289}=0.06082. \]

This is a small positive standardized difference under the stated convention: the adjusted treated-group prevalence is higher by 0.0200, or 2.00 percentage points, and the difference is 0.06082 corrected-feature standard deviations. The denominator from the original, incorrectly timed feature cannot be reused: changing which claims define the feature changes its original-cohort distribution and therefore its scale. If the corrected feature’s original prevalences were unavailable, its fixed-scale SMD could not be determined from the adjusted prevalences alone.

Worked Example: Locating a Procedure-Block Discrepancy

Consider a hypothetical procedure indicator, “any qualifying procedure during the pretreatment year.” Its original prevalences are 0.04 in the treated group and 0.02 in the comparison group. After adjustment, they are 0.035 and 0.018. Calculate the fixed-scale SMD, then state a sensible diagnostic next step.

The original pooled standard deviation is \[ \sqrt{\frac{0.04(0.96)+0.02(0.98)}{2}} =\sqrt{\frac{0.0384+0.0196}{2}} =\sqrt{0.02900} =0.1703. \] The adjusted difference is \(0.035-0.018=0.0170\), so \[ SMD=\frac{0.0170}{0.1703}=0.09982. \] The adjusted treated prevalence is higher by 1.70 percentage points, and the standardized difference is about 0.09982. This result is a diagnostic signal, not a hypothesis-test result. Before changing the model, inspect the procedure’s code list, date window, and eligibility rules in both treatment groups. Confirm that the indicator means the same thing for everyone and was measured before treatment assignment. A clinically plausible indicator can still be misconstructed or inconsistently captured.

Tracing Imbalance to Feature Construction

Block patterns help organize investigation, but they do not identify their cause automatically. A high diagnosis-block RMS might reflect genuine baseline differences, inconsistent code mapping, or a lookback window that captures different amounts of history for different people. A medication-block discrepancy could arise from a drug-class definition that combines unlike products or from claims recorded under different coding conventions. Procedure imbalance may point to a narrow code list or a distinction between inpatient and outpatient claims. Utilization imbalance may reflect incomplete capture of visits, an inconsistent enrollment requirement, or an indicator that counts encounters differently across groups.

The investigation should follow a transparent sequence. First, verify that all features represent information available before treatment assignment; post-treatment information must not be treated as a baseline confounder. Second, verify the feature definition: source fields, code lists, aggregation rules, missing-data handling, lookback period, and whether an indicator means “ever,” “count,” or “recent.” Third, check that the same rules were applied in both groups and across calendar time. Fourth, inspect individual features within the block and compare their original and adjusted distributions. Finally, revisit selection decisions: determine whether a block was truncated, features were excluded by prevalence or coding rules, or a selected feature was represented only by a broad aggregate that conceals meaningful subgroups.

A persistent imbalance is not, by itself, proof that a particular feature must be added or that a model must be made more complex. Selection should remain guided by the causal structure and the intended estimand, not solely by which adjustment produces the smallest balance statistic. Conditioning on a variable affected by treatment or on a collider can introduce bias even if it improves a numerical balance summary. The earlier material on causal structure constraints and avoiding collider adjustment remains relevant when considering a feature change.

Short Justification: Why Use RMS and the Maximum Together?

The signed mean SMD of a block is a poor summary because positive and negative differences can cancel. Squaring each SMD before averaging prevents that cancellation, and taking the square root returns the summary to the original standardized scale. For the two-feature example above, the signed average would be \((0.4472-0.1516)/2=0.1478\), which understates the size of the larger discrepancy. The RMS instead gives 0.3339. But even RMS can be moderate when most features are near zero and one feature is very large. The maximum absolute SMD exposes that possibility, while \(Q_B(c)\) describes how broadly a chosen threshold is exceeded. These summaries answer different questions, so they are most informative together with the feature-level values.

Diagnostics, Comparisons, and Limits

A block summary should be treated as a map for review, not a verdict. Examine a feature-level table or plot with signed SMDs, block membership, original prevalences or means, and adjusted prevalences or means. Look for clusters, abrupt differences between related codes, and features whose coding definitions changed across sites or time. Recalculate summaries after correcting a verified data-definition problem, using the revised original-cohort distribution for the fixed denominator. Keep an audit trail of the original and revised definitions.

Several common alternatives answer narrower questions. A single overall average across all features may be dominated by a large block and hide another block’s residual imbalance. Individual SMDs can reveal the exact feature but may be difficult to scan across thousands of features. A balance plot is useful for locating outliers and patterns, while block RMS and maximum values provide compact summaries. Conventional significance tests are generally not substitutes for these diagnostics: their p-values depend strongly on sample size and do not measure the magnitude of imbalance on a comparable scale. None of these summaries measures imbalance in unobserved variables.

Interpret thresholds cautiously. A value such as 0.1 is often used as a practical flag in balance assessment, but it is not a theorem guaranteeing negligible confounding below the cutoff or serious bias above it. Clinical importance, feature prevalence, measurement quality, the design, and the target estimand all matter. High-dimensional blocks also contain correlated features; treating every code as an independent piece of evidence exaggerates how many distinct problems a block contains. Conversely, a low block RMS can conceal a single important feature, which is why \(M_B\) and feature-level inspection matter.

Block diagnostics do not establish that the propensity model is correctly specified, that treatment groups have adequate overlap, or that the causal assumptions are satisfied. They describe measured covariate distributions after a design procedure. If a block shows a problem, the next step is to distinguish a data-construction issue from a modeling or selection issue, while preserving pretreatment timing and the causal rationale for adjustment.

Common Mistake

Common mistake: “The diagnosis block’s RMS improved after I changed the code window, so I can keep the old denominator and compare the new adjusted difference on the original scale.”

Correction: If the feature definition changes, its pre-adjustment distribution may change too. Recalculate the denominator from the corrected feature’s original-group prevalences or variances, then compute the adjusted SMD. If those corrected pre-adjustment quantities are not available, the corrected fixed-scale SMD is not determined. Also inspect the individual feature values: an improved RMS alone may conceal a persistent, important imbalance.
Key takeaway: Summarize residual imbalance by diagnosis, medication, procedure, and utilization blocks, but always retain feature-level diagnostics. When a block looks problematic, check timing, code definitions, data capture, and selection choices before interpreting the pattern as a modeling failure.

Check Your Understanding

Answer each question, then compare your reasoning with the solutions below.

  1. A binary feature has original prevalences 0.25 and 0.15, and adjusted prevalences 0.20 and 0.17. Calculate its fixed-scale SMD and interpret its sign.
  2. Why can the signed average of SMDs be misleading for a block? Name two complementary summaries.
  3. A team changes a diagnosis feature to exclude post-treatment claims but reports an SMD using the old feature’s original standard deviation. What is wrong, and what information is needed?
  4. A utilization block has a small RMS but one feature has a large absolute SMD. What should be reported and investigated?
  5. Does good balance across measured feature blocks establish that the estimated treatment effect is unbiased? Explain.

Solutions. (1) The denominator is \(\sqrt{[0.25(0.75)+0.15(0.85)]/2}=\sqrt{(0.1875+0.1275)/2}=\sqrt{0.1575}=0.3969\). The adjusted difference is \(0.20-0.17=0.0300\), so \(SMD=0.0300/0.3969=0.07559\). The positive sign means the adjusted treated prevalence is higher by 3.00 percentage points. (2) Positive and negative feature differences can cancel; report RMS and maximum absolute SMD, and inspect feature-level values. (3) The changed definition can have a different original-cohort distribution, so the old denominator is not justified. Recompute original-group prevalences for the corrected feature, calculate its pooled binary standard deviation, and then divide the adjusted difference by that scale. Without the corrected original prevalences, the fixed-scale SMD cannot be calculated. (4) Report the RMS, maximum, threshold-exceedance share, and the individual feature; inspect its timing, coding, and data-capture rules. (5) No. Balance describes measured features only; it does not establish no unmeasured confounding, correct measurement, or all assumptions needed for a causal interpretation.

Clinical Biostats