Tutorials › Multi-Omics Data Integration › Comparing Models On The Same Held-Out Subjects

Prediction Models and Data Leakage · Tutorial 421 of 597

Comparing Models On The Same Held-Out Subjects

You will learn to estimate and quantify uncertainty in the performance difference between two models evaluated on identical held-out subjects.

Advanced 12 min read

What You'll Learn

  • Define a subject-level paired difference and state which direction represents better performance.
  • Derive the standard error of a paired mean difference and explain how within-subject correlation affects it.
  • Construct and interpret a paired t interval under its assumptions.
  • Use a subject-level paired bootstrap for metrics that are not averages of subject-level scores.
  • Distinguish uncertainty from sampling held-out subjects from uncertainty due to model training or selection.
  • Diagnose pairing, clustering, and metric-specific problems that can make an uncertainty estimate misleading.

Why the Comparison Must Preserve Pairing

When two prediction pipelines are evaluated on the same held-out subjects, each subject contributes an outcome and a prediction from both models. The two performance results are therefore paired: for a given subject, the models face the same outcome and often the same subject-specific difficulty. Comparing two overall scores as if they came from unrelated groups discards that pairing and can misstate uncertainty.

The target of a comparison should be specified before calculating it. For an additive subject-level loss, a useful target is the mean difference in loss across the population represented by the held-out sample. If lower loss is better, define the difference so a positive value favors model A. For a score where higher is better, use the corresponding reverse subtraction. This direction convention makes the sign of the result interpretable, but it does not make a difference practically important by itself.

Definition: For held-out subject \(i\), let \(L_{Ai}\) and \(L_{Bi}\) be the losses from models A and B, respectively, calculated using the same subject’s outcome and predictions. Define \(d_i=L_{Bi}-L_{Ai}\), so \(d_i>0\) favors A. The paired mean difference is \(\bar{d}=\frac{1}{n}\sum_{i=1}^{n}d_i\), the average improvement in loss for A relative to B. A loss difference is measured in the units of that loss.

For example, the Brier score for a binary outcome is the squared difference between the observed outcome, coded 0 or 1, and its predicted probability. It is a dimensionless loss, with smaller values better. With the definition above, a positive mean difference in Brier score means model A has lower average Brier loss. For an outcome measured in years, a difference in absolute prediction error would instead be measured in years.

Pairing requires that the two predictions be evaluated against the same subjects and the same outcome values. It does not mean that the models are statistically independent; indeed, their errors are commonly correlated. The held-out subjects must also be independent sampling units for the basic subject-level procedures below. If several observations come from the same patient, family, or site, treating all rows as independent can understate uncertainty.

Paired Mean Differences and Their Uncertainty

Suppose each subject contributes one difference \(d_i\), and the held-out subjects are an independent and identically distributed sample from the population to which the comparison is intended to apply. The sample standard deviation of the differences is \(s_d\), and the standard error of their mean is \(SE(\bar{d})=s_d/\sqrt{n}\). This standard error is calculated from the differences, not by separately estimating uncertainty for each model and combining the results as though the models were evaluated on different people.

$$ s_d=\sqrt{\frac{\sum_{i=1}^{n}(d_i-\bar{d})^2}{n-1}}, \qquad SE(\bar{d})=\frac{s_d}{\sqrt{n}}. $$

The reason pairing matters can be seen from the variance of a difference. If the two subject-level losses have variances \(\sigma_A^2\) and \(\sigma_B^2\), and covariance \(\operatorname{Cov}(L_A,L_B)\), then

$$ \operatorname{Var}(L_B-L_A) =\sigma_B^2+\sigma_A^2-2\operatorname{Cov}(L_A,L_B). $$

Because both models are scored on the same subject, their losses may have positive covariance: a difficult subject may produce a relatively large loss for both. Positive covariance reduces the variance of the difference. An unpaired calculation omits this covariance term and does not use the actual sampling structure.

A paired \(t\) interval for the mean difference is

$$ \bar{d}\ \pm\ t_{1-\alpha/2,\,n-1}\frac{s_d}{\sqrt{n}}. $$

This interval is exact when the differences \(d_1,\ldots,d_n\) are independent and identically distributed normal observations with a common mean and a common variance. Independence and normality of each difference alone are not sufficient if the differences have unequal variances or different means. For larger samples, the interval is often used as an approximation when the differences are independent and identically distributed with finite variance and no extreme observations dominate the mean. With a small sample, substantial skewness or outliers can make that approximation unreliable.

Worked Example: A Paired Interval for Brier Loss

Consider eight hypothetical, independent held-out subjects. For each subject, calculate \(d_i=L_{Bi}-L_{Ai}\), where both \(L\)'s are Brier scores. Suppose the resulting dimensionless differences are \(0.04,\ 0.02,\ 0.03,\ -0.01,\ 0.05,\ 0.00,\ 0.02,\ 0.03\). Positive values favor A. Assume for this illustration that these differences are an independent, identically distributed sample from a normal population with a common mean and variance.

The sum of the differences is \(0.18\), so \(\bar{d}=0.18/8=0.0225\). The sum of squared deviations from the mean is \(0.00275\). Therefore,

$$ s_d=\sqrt{\frac{0.00275}{7}}=0.01982, \qquad SE(\bar{d})=\frac{0.01982}{\sqrt{8}}=0.007007. $$

For a 95% interval with \(df=7\), the critical value is approximately \(t_{0.975,7}=2.365\). The margin of error is \(2.365(0.007007)=0.01657\), giving

$$ 0.0225\ \pm\ 0.01657=(0.00593,\ 0.03907). $$

Under the stated sampling and normality assumptions, the interval procedure has 95% coverage for the population mean improvement in Brier loss. In this example, the interval’s endpoints correspond to an improvement from about 0.00593 to 0.03907 Brier-score units for A relative to B. The interval excludes zero, but it describes an average difference, not a guarantee that A improves prediction for every subject. Whether an improvement of this size is useful depends on the application.

Metrics That Are Not Subject-Level Averages

Not every performance metric is the average of one score per subject. The area under the receiver operating characteristic curve (AUC), for instance, is based on comparisons between positive and negative subjects. It cannot generally be reduced to a simple average of independent subject-level AUC contributions. Applying the paired \(t\) formula to invented per-subject AUC values is not justified.

A paired subject bootstrap is one way to quantify sampling uncertainty for a difference in such metrics. Resample subjects, retaining each subject’s outcome and both models’ predictions together. For each resampled data set, calculate both metrics and their difference. The same resampled subjects and multiplicities must be used for both models in every replicate; otherwise the pairing is broken. For AUC, resamples must contain both outcome classes. A stratified bootstrap resamples within each outcome class and targets uncertainty conditional on the observed class counts; an unstratified bootstrap instead reflects variation in class counts as well, provided the replicates permit the metric to be calculated.

Worked Example: Paired Bootstrap for an AUC Difference

Suppose two hypothetical classifiers are evaluated on the same six held-out subjects, with three positive and three negative outcomes. Their observed AUCs are 0.778 for A and 0.667 for B, so the observed difference \(AUC_A-AUC_B\) is \(0.778-0.667=0.111\). Because AUC is not an average of independent subject-level scores, use a paired bootstrap rather than a paired \(t\) interval on six supposed AUC contributions.

For each of 1,000 hypothetical stratified bootstrap replicates, sample three positive subjects with replacement and three negative subjects with replacement. Carry both models’ predictions along whenever a subject is sampled, then recalculate each AUC and subtract B’s AUC from A’s. Suppose the resulting 1,000 paired differences have a 2.5th percentile of \(-0.111\) and a 97.5th percentile of \(0.333\). The percentile interval is therefore \((-0.111,\ 0.333)\) AUC units.

This interval includes zero, so these illustrative data do not establish a nonzero AUC difference at the 95% interval level. The interval is an approximate bootstrap interval, not an exact small-sample result; six subjects are far too few for its endpoints to be treated as dependable. In an actual analysis, the number of subjects, number in each class, and stability of the bootstrap distribution matter. Resampling model A’s subjects independently from model B’s subjects would answer a different, unpaired question and produce an inappropriate comparison for this design.

Worked Comparison of Paired and Unpaired Uncertainty

The effect of dependence can be substantial even when the observed model performances are similar. For a simple illustration, suppose subject-level losses have standard deviations \(0.10\) for A and \(0.09\) for B, and their within-subject correlation is \(0.80\). The covariance is \(0.80(0.10)(0.09)=0.0072\). Thus, the variance of the paired loss difference is

$$ 0.10^2+0.09^2-2(0.0072)=0.0037. $$

The standard deviation of a paired difference is \(\sqrt{0.0037}=0.06083\). For \(n=100\) independent subjects, the standard error of the mean paired difference is \(0.06083/\sqrt{100}=0.006083\). By contrast, a calculation that incorrectly treats the two model evaluations as independent gives \(\sqrt{(0.10^2+0.09^2)/100}=0.01345\). The latter is more than twice as large in this particular setting because it discards positive within-subject correlation. The direction and magnitude of the error are not guaranteed in all settings; the correct calculation follows the paired sampling design.

Worked Example: The Same Subjects Are Essential

A hypothetical evaluation reports average absolute errors of 4.2 days for model A and 5.0 days for model B on the same patients. The difference in the two reported averages is \(5.0-4.2=0.8\) days, favoring A. These two averages alone do not provide the standard deviation of the paired differences, so they are insufficient to construct a paired \(t\) interval.

Suppose the patient-level errors are available and the computed differences \(d_i=|e_{Bi}|-|e_{Ai}|\) have \(n=100\), \(\bar{d}=0.8\) days, and \(s_d=3.0\) days. Then \(SE(\bar{d})=3.0/\sqrt{100}=0.30\) days. Using the large-sample normal critical value 1.96 as an approximation gives \(0.8\pm1.96(0.30)=(0.212,\ 1.388)\) days. This approximate interval suggests an average reduction in absolute error for A between about 0.212 and 1.388 days, subject to the sampling assumptions and the adequacy of the approximation. The paired difference distribution should be inspected for severe skewness or influential observations; knowing only the two overall averages would not reveal those issues.

Assumptions, Diagnostics, and Scope

A paired comparison is informative only when the evaluation design supports it. The following checks address different potential failures:

  • Confirm the pairing. Verify that each included subject has an outcome and predictions from both models, and that the same outcome definition and eligibility rules were used. Do not pair records by row position unless the subject identifiers confirm the match.
  • Check the sampling unit. If observations are repeated within a patient or clustered within a site, the rows may not be independent. Use a method that resamples or models the independent units, such as resampling patients or sites as appropriate, rather than treating repeated rows as separate subjects.
  • Inspect the differences, not just the model scores. For a paired \(t\) interval, examine a plot or summary of \(d_i\) for skewness, outliers, and data errors. With small \(n\), these features can undermine the normal approximation. An extreme difference may be real, so investigate it rather than deleting it automatically.
  • Check the metric and its direction. Confirm that a larger difference consistently favors the intended model and that the metric is suitable for the outcome and class balance. A mean difference in a loss is not the same estimand as a difference in AUC or calibration.
  • Keep the held-out evaluation separate from model development. Pairing addresses uncertainty in the comparison on shared evaluation subjects; it cannot repair leakage, test-set reuse, or model selection based on held-out outcomes.

The paired \(t\) interval or subject bootstrap generally describes sampling variability across held-out subjects conditional on the fitted models and the evaluation procedure used. It does not, by itself, include variability from drawing a new training set, refitting the pipelines, or repeating model selection and tuning. If those sources are part of the intended target, the evaluation design must reproduce them when estimating uncertainty. Likewise, if the held-out subjects are a fixed finite set and the only target is performance on exactly that set, the computed difference is descriptive for that set; a sampling interval requires a population-sampling interpretation.

The main alternative to the paired approach is an unpaired comparison, which is appropriate only when the models are evaluated on distinct independent samples and the target is defined accordingly. It is not an acceptable shortcut for shared subjects. Bootstrap procedures are useful for complex metrics, but they are not automatically reliable in tiny samples or when the resampling scheme fails to represent the sampling design. The method should follow the estimand and dependence structure, rather than the convenience of a software function.

Common Mistakes

  • Using separate standard errors for two scores on shared subjects. This ignores the covariance between the model results. Calculate subject-level paired differences, or use a paired resampling procedure for a non-additive metric.
  • Assuming normality alone gives an exact paired \(t\) interval. Exactness requires independent and identically distributed normal differences with a common mean and variance. Independent normal differences with unequal variances do not in general yield the usual \(t\) distribution.
  • Interpreting an interval as a probability statement about the parameter. A 95% confidence procedure has 95% long-run coverage under its assumptions; it does not mean there is a 95% probability that this particular interval contains the fixed population mean.
  • Confusing statistical evidence with practical value. An interval excluding zero does not establish that the difference is large enough to matter clinically or operationally. Interpret its units and compare it with a relevant practical threshold.
  • Treating every row as an independent subject. Repeated measures or clustered observations can create dependence beyond the pairing of models. Resample or analyze the independent sampling units.
Key takeaway: For models scored on the same held-out subjects, compare like with like: preserve the subject pairing, define a signed difference with clear units, and quantify uncertainty using assumptions that match both the metric and the sampling design.

Check Your Understanding

Answer each question, then compare with the brief solutions below.

  1. For a loss where smaller is better, define a paired difference so a positive value favors model A.
  2. What conditions make the usual paired \(t\) interval exact?
  3. Two models have correlated subject-level losses. Why is it wrong to treat their estimates as independent when they were scored on the same subjects?
  4. Why is a paired \(t\) interval on per-subject AUC contributions generally not justified?
  5. A study has repeated visits per patient. What must be considered before using a subject-level standard error?

Solutions. (1) Use \(d_i=L_{Bi}-L_{Ai}\); positive values indicate lower loss for A. (2) The differences must be independent and identically distributed normal observations with a common mean and variance. (3) The paired observations have covariance, which enters the variance of their difference; ignoring it fails to reflect the design. (4) AUC is based on positive-negative subject comparisons, not generally an average of independent subject-level contributions. A paired bootstrap can preserve the paired predictions while recalculating AUC. (5) Visits from a patient may be dependent, so patients—not visits—may need to be the resampling or independent units.

Clinical Biostats