Why Compare Entire Distributions?
Balance diagnostics should show whether the treatment and comparison groups have similar covariate distributions after the chosen matching or weighting procedure. A difference in means can miss important features: two groups may have the same mean while differing in spread, skewness, or tails. Quantile-quantile plots help reveal such patterns; empirical cumulative distribution functions (ECDFs) provide another direct comparison, and the Kolmogorov–Smirnov (KS) distance reduces that comparison to one number.
The KS distance is a descriptive summary of the largest gap between the groups’ cumulative distributions. It answers a specific question: across all possible cut points on the covariate scale, what is the greatest difference in the proportions of the two groups at or below a cut point? It can flag distributional imbalance that a mean-based summary does not show. It does not, by itself, determine whether matching or weighting succeeded for every covariate or establish that a causal estimate is unbiased.
Empirical Cumulative Distribution Functions
In a balance assessment, calculate one ECDF for the treated group and one for the comparison group using the same covariate and the same measurement scale. Each curve gives the fraction of that group with covariate values no greater than \(x\). For example, if the treated ECDF at \(x=10\) is 0.70, then 70% of the treated observations have values at or below 10.
The ECDF is right-continuous: at an observed value, it includes all observations tied at that value. Ties therefore produce jumps larger than \(1/n\). This is not a defect; it reflects the observed data. Although the covariate of interest is often continuous in principle, recorded measurements may have ties because of rounding or a discrete measurement scale.
The Kolmogorov–Smirnov Distance
For any cut point \(x\), the signed difference \(\widehat{F}_T(x)-\widehat{F}_C(x)\) compares the treated and comparison proportions at or below \(x\). The absolute value measures the size of that discrepancy without regard to its direction. The largest absolute difference over all cut points is \(D\). For finite samples, the maximum can be found by checking the observed covariate values in both groups, including tied values. Between consecutive distinct observed values, neither ECDF changes, so their difference is constant.
The distance is expressed on a proportion scale, not in the covariate’s measurement units. If \(D=0.20\), then at the cut point where the maximum occurs, the groups’ cumulative proportions differ by 20 percentage points. That does not mean every cut point differs by 20 points, nor does it say which group has larger covariate values overall. To understand direction and location, inspect the signed difference and the ECDF curves as well as \(D\).
Worked Example: Calculating the Distance From Two Small Samples
Suppose a hypothetical matched sample has treated covariate values 2, 4, 5, 8, 9 and comparison values 1, 3, 4, 6, 10. The groups are measured on the same scale, and each listed observation receives equal weight. At each distinct observed value, calculate both ECDFs and their absolute difference.
| Cut point \(x\) | \(\widehat{F}_T(x)\) | \(\widehat{F}_C(x)\) | Absolute difference |
|---|---|---|---|
| 1 | 0/5 = 0.00 | 1/5 = 0.20 | 0.20 |
| 2 | 1/5 = 0.20 | 1/5 = 0.20 | 0.00 |
| 3 | 1/5 = 0.20 | 2/5 = 0.40 | 0.20 |
| 4 | 2/5 = 0.40 | 3/5 = 0.60 | 0.20 |
| 5 | 3/5 = 0.60 | 3/5 = 0.60 | 0.00 |
| 6 | 3/5 = 0.60 | 4/5 = 0.80 | 0.20 |
| 8 | 4/5 = 0.80 | 4/5 = 0.80 | 0.00 |
| 9 | 5/5 = 1.00 | 4/5 = 0.80 | 0.20 |
| 10 | 5/5 = 1.00 | 5/5 = 1.00 | 0.00 |
The maximum absolute difference is 0.20, so \(D=0.20\). For instance, at \(x=9\), the treated cumulative proportion is \(5/5=1.00\), while the comparison cumulative proportion is \(4/5=0.80\); their difference is \(1.00-0.80=0.20\). In this small hypothetical sample, the largest observed gap is 20 percentage points. The result alone does not indicate a large or acceptable imbalance: that judgment requires context, the ECDF shape, and the goals of the analysis.
Justification and a Second Distribution Pattern
The calculation follows directly from what an ECDF represents. At each \(x\), \(\widehat{F}_T(x)\) and \(\widehat{F}_C(x)\) are the respective fractions at or below that cut point. Their difference is therefore the difference in cumulative fractions at \(x\). Taking the absolute value removes the sign, and taking the supremum selects the greatest discrepancy across the covariate scale. In finite data, each curve changes only at observed values, so comparing the curves at the pooled set of observed values is sufficient to obtain the maximum.
Worked Example: Ties and a Large Cumulative Gap
Consider hypothetical treated values 3, 4, 5, 6, 7 and comparison values 1, 1, 2, 2, 3, with equal weight per observation. Ties in the comparison group create jumps of two observations, or \(2/5=0.40\). At \(x=1\), the ECDFs are \(0.00\) and \(2/5=0.40\). At \(x=2\), they are \(0.00\) and \(4/5=0.80\). At \(x=3\), they are \(1/5=0.20\) and \(5/5=1.00\).
The absolute differences at these points are 0.40, 0.80, and 0.80. At \(x=4,5,6,7\), the comparison ECDF remains 1.00, while the treated ECDF is \(2/5,3/5,4/5,1\); the corresponding absolute differences are 0.60, 0.40, 0.20, and 0.00. Thus the maximum is \(D=0.80\), attained at \(x=2\) and \(x=3\). In this hypothetical example, the groups have sharply different cumulative distributions: at \(x=2\), 0% of treated observations and 80% of comparison observations are at or below the cut point.
This example also illustrates why calculations must include ties correctly. At \(x=1\), both comparison observations equal to 1 are counted; counting only one would incorrectly report an ECDF of \(1/5\) instead of \(2/5\).
Weighted ECDFs After Weighting
When a balance assessment concerns a weighted sample, an unweighted ECDF describes the observed sample rather than the weighted target distribution. For nonnegative weights \(w_i\) with positive total weight, the weighted ECDF is the weighted fraction at or below \(x\):
Calculate this ECDF separately for each group, normalizing by that group’s total weight. Then use the same supremum-of-absolute-differences definition for the weighted KS distance. The weights must be nonnegative for this expression to represent a cumulative distribution. The covariate and its units must be the same in both groups, and the weights should be those defining the weighted comparison being diagnosed.
Worked Example: A Weighted KS Distance
In a hypothetical weighted comparison, treated covariate values are 2, 5, and 8 with weights 1, 1, and 2. Comparison values are 1, 4, and 7 with weights 1, 2, and 1. Each group’s total weight is 4, so the ECDFs can be evaluated at the pooled values 1, 2, 4, 5, 7, and 8.
At \(x=1\), the treated weighted ECDF is \(0/4=0\), and the comparison weighted ECDF is \(1/4=0.25\), giving an absolute difference of 0.25. At \(x=2\), the values are \(1/4=0.25\) and \(1/4=0.25\), giving 0. At \(x=4\), they are \(1/4=0.25\) and \((1+2)/4=0.75\), giving 0.50. At \(x=5\), they are \(2/4=0.50\) and \(3/4=0.75\), giving 0.25. At \(x=7\), they are \(2/4=0.50\) and \(4/4=1.00\), giving 0.50. At \(x=8\), both equal 1.00, giving 0.
The largest gap is \(D=0.50\), attained at \(x=4\) and \(x=7\). For example, at \(x=4\), the weighted cumulative proportions are 25% and 75%, a difference of 50 percentage points. Normalizing each group by its own total weight is essential; summing the weights below a cut point without dividing by the group total would not yield an ECDF.
Reading the Diagnostic and Recognizing Its Limits
The KS distance is useful because it assesses a distributional feature across the whole covariate scale rather than at only one summary, such as the mean. A large distance can reveal a localized gap, a broad shift, or a tail difference. The distance does not identify which pattern produced it. Plotting both ECDFs helps locate where they separate; the signed difference helps identify which group has the larger cumulative proportion there. A smaller ECDF at a given \(x\) means a smaller fraction of that group is at or below \(x\), not automatically that the entire group is larger at every point.
Treat \(D\) as a descriptive balance diagnostic, not as an automatic pass/fail rule. Its interpretation depends on the covariate, study context, and intended analysis. A distance that appears modest may still matter if it occurs in a consequential region of the covariate distribution. Conversely, the distance does not communicate every feature of the distribution. It can also be affected by sparse observations and ties, especially in small samples.
The calculation does not require independent sampling as a condition for the descriptive comparison itself: it is computed from the two empirical distributions at hand. However, an inferential KS test and its p-value answer a different question and require assumptions appropriate to that inferential procedure. After matching or weighting, dependence induced by the design and the construction of the weights make an off-the-shelf two-sample p-value an inappropriate substitute for balance assessment. A small p-value is not a measure of practical imbalance, and a large one does not establish balance.
The ECDF comparison is univariate: it evaluates one covariate at a time. A set of small distances does not establish that the joint distribution of all covariates is balanced, and a distance for one covariate cannot diagnose imbalance in interactions or subgroups. It also cannot verify that the matching or weighting procedure made the right causal assumptions. Interpret it alongside other relevant diagnostics rather than treating a single number as a guarantee.
How It Compares With Other Balance Summaries
| Diagnostic | What it summarizes | What it can miss or add |
|---|---|---|
| Standardized mean difference | Difference in group means on a standardized scale | Useful for mean balance; can miss differences in spread, shape, and tails |
| Variance ratio | Relative group variances | Highlights spread differences; does not describe all distributional differences |
| Quantile-quantile plot | Corresponding quantiles across groups | Shows where quantiles differ; is graphical rather than a single maximum cumulative gap |
| ECDF and KS distance | Cumulative proportions across cut points and their largest absolute gap | Summarizes the maximum gap; the curves are needed to see its location and shape |
These diagnostics address related but nonidentical features. For example, quantile-quantile plots compare values at corresponding quantiles, while the KS distance compares cumulative proportions at common cut points. The ECDF display and its distance complement rather than replace mean differences, variance ratios, and quantile-quantile plots.
Common Pitfalls
- Using only the mean. Equal means do not imply equal distributions. Compare ECDFs when the aim includes checking distributional shape across the covariate range.
- Reporting a distance without its meaning. State that \(D\) is the maximum absolute difference in cumulative proportions, and give its proportion-scale interpretation.
- Ignoring the curves’ direction. Because \(D\) is absolute, it does not tell which group has the larger cumulative proportion at the maximizing cut point. Inspect the signed difference or both ECDFs.
- Dropping ties or using the wrong denominator. Include every observation at or below the cut point and divide by the group sample size, or by the group’s total weight for a weighted ECDF.
- Treating a KS test p-value as a balance score. A descriptive distance and an inferential test are not interchangeable. Balance assessment focuses on the observed distributions, not a test of whether a population-level null can be rejected.
Check Your Understanding
Answer each question, then compare your reasoning with the solutions.
- A treated ECDF is 0.35 at \(x=12\), and a comparison ECDF is 0.55 there. What is the absolute difference, and what does it mean in context?
- Two groups have equal means but different ECDFs. Is that possible? Explain what the KS distance would summarize.
- For treated values 1, 3, 5 and comparison values 2, 3, 4, all equally weighted, calculate the KS distance.
- In a weighted ECDF, the total weight in one group is 10, and weight 3 belongs to observations at or below a chosen \(x\). What is the weighted ECDF at \(x\)?
Solutions. (1) The absolute difference is \(|0.35-0.55|=0.20\). At \(x=12\), the cumulative proportions differ by 20 percentage points; the comparison group has the larger proportion at or below 12. This is the gap at that cut point, not necessarily the overall KS distance. (2) Yes. Equal means do not require equal spreads or shapes. The KS distance summarizes the largest absolute difference between the groups’ cumulative proportions over all cut points. (3) At pooled cut points 1, 2, 3, 4, and 5, the ECDF pairs are \((1/3,0)\), \((1/3,1/3)\), \((2/3,2/3)\), \((2/3,1)\), and \((1,1)\). The absolute differences are \(1/3,0,0,1/3,0\), so \(D=1/3\), or about 0.333. (4) The weighted ECDF is \(3/10=0.30\). It represents 30% of that group’s total weight at or below \(x\).