Why Compare Risks in Pairs?
When two ensembles are evaluated on the same test observations, their errors are naturally paired: each observation supplies one loss for ensemble A and one for ensemble B. The difference between those losses, observation by observation, is often more informative than treating the two lists of losses as unrelated. If an observation is difficult for both ensembles, that shared difficulty can contribute little to their difference.
The goal here is to quantify uncertainty in the difference between two risks. A negative estimated difference will favor A under the convention below; a positive one will favor B. The size of the uncertainty depends not only on how variable each ensemble’s losses are, but also on how the two losses co-vary on the same observations.
Risk Difference and Paired Data
Let \(Z=(X,Y)\) denote a new observation from the evaluation population, and let \(\hat f_A\) and \(\hat f_B\) be two fitted ensembles. For a specified loss function \(\ell\), define their losses on \(Z\) by \(L_A=\ell(Y,\hat f_A(X))\) and \(L_B=\ell(Y,\hat f_B(X))\). The fitted ensembles are treated as fixed for the comparison. If they were trained on random data independent of the evaluation sample, these definitions and results can instead be read conditionally on the training data.
The pairing is part of the data structure: \(L_{Ai}\) and \(L_{Bi}\) come from the same \(Z_i\). The risk difference concerns their expected difference, not the difference between losses from two independently sampled evaluation sets.
Worked Example: Paired Zero-One Losses
Suppose each ensemble’s loss is a zero-one loss, so it is 1 for a mistake and 0 otherwise. Across a randomly drawn evaluation observation, the joint probabilities of the two losses are \(P(L_A=1,L_B=1)=0.15\), \(P(L_A=1,L_B=0)=0.05\), \(P(L_A=0,L_B=1)=0.10\), and \(P(L_A=0,L_B=0)=0.70\). These four probabilities are nonnegative and sum to 1.
The risks are \(R_A=0.15+0.05=0.20\) and \(R_B=0.15+0.10=0.25\), so \(\Delta=-0.05\): A has lower risk by 0.05. The covariance of the paired losses is \(\operatorname{Cov}(L_A,L_B)=E[L_A L_B]-E[L_A]E[L_B]=0.15-(0.20)(0.25)=0.10\).
Because a zero-one loss with error probability \(p\) has variance \(p(1-p)\), the variance of one paired difference is \(0.20(0.80)+0.25(0.75)-2(0.10)=0.1475\). Thus, for \(n\) independent evaluation observations, the variance of \(\hat\Delta\) is \(0.1475/n\). If we incorrectly treated the two losses as independent, we would omit the covariance term and obtain \((0.16+0.1875)/n=0.3475/n\). Here, ignoring pairing more than doubles the estimated variance.
Exact Variance of the Paired Risk Difference
Proof. Since the observations are identically distributed, each \(D_i=L_{Ai}-L_{Bi}\) has expectation \(E[D_i]=R_A-R_B=\Delta\). Linearity of expectation gives \(E[\hat\Delta]=n^{-1}\sum_{i=1}^n E[D_i]=\Delta\). Independence of the evaluation observations makes the \(D_i\) independent, so \(\operatorname{Var}(\hat\Delta)=n^{-2}\sum_{i=1}^n\operatorname{Var}(D_i)=\operatorname{Var}(D_1)/n\). Finally, expanding the variance of a difference gives \(\operatorname{Var}(L_A-L_B)=\operatorname{Var}(L_A)+\operatorname{Var}(L_B)-2\operatorname{Cov}(L_A,L_B)\). The finite second-moment assumptions ensure these variances and covariances exist. \(\square\)
This identity explains the role of pairing. Positive covariance reduces the variance of the difference relative to the sum of the two marginal variances; negative covariance increases it. The comparison is not automatically precise just because the ensembles share some predictions or training data: what matters directly is the covariance of their losses on the evaluation distribution.
Estimating Uncertainty From the Paired Differences
The population variance of \(D_i\) is generally unknown. Compute the observed differences \(d_i=L_{Ai}-L_{Bi}\), their mean \(\bar d=\hat\Delta\), and their sample variance:
The estimated standard error of the paired risk difference is \(s_D/\sqrt{n}\). This estimate uses the empirical variability of the differences themselves, so it automatically incorporates the observed association between A’s and B’s losses.
To verify the unbiasedness, write \(\mu_D=E[D_i]\) and \(\sigma_D^2=\operatorname{Var}(D_i)\). The identity \(\sum_{i=1}^n(D_i-\bar D)^2=\sum_{i=1}^n(D_i-\mu_D)^2-n(\bar D-\mu_D)^2\) implies, on taking expectations, that the left side has expectation \(n\sigma_D^2-n(\sigma_D^2/n)=(n-1)\sigma_D^2\). Dividing by \(n-1\) proves \(E[s_D^2]=\sigma_D^2\). Since \(n\) is fixed, \(E[s_D^2/n]=\sigma_D^2/n=\operatorname{Var}(\hat\Delta)\).
For large \(n\), if the paired differences are identically distributed with finite, nonzero variance, the central limit theorem and Slutsky’s theorem give \((\hat\Delta-\Delta)/(s_D/\sqrt n)\xrightarrow{d}N(0,1)\). This motivates an approximate confidence interval \(\hat\Delta\pm z_{1-\alpha/2}s_D/\sqrt n\), where \(z_{1-\alpha/2}\) is the corresponding standard normal quantile. This is an asymptotic interval, not an exact finite-sample guarantee. In particular, paired differences need not be normally distributed merely because the two ensemble losses have simple marginal distributions.
Worked Example: Computing a Paired Standard Error
On four evaluation observations, suppose the observed losses are as follows. The last column preserves the pairing and subtracts B’s loss from A’s loss.
| Observation | A loss | B loss | Difference \(d_i\) |
|---|---|---|---|
| 1 | 1 | 2 | \(-1\) |
| 2 | 4 | 3 | \(1\) |
| 3 | 2 | 4 | \(-2\) |
| 4 | 5 | 4 | \(1\) |
The estimated risk difference is \(\bar d=(-1+1-2+1)/4=-0.25\), so the observed risks favor A. The deviations from \(\bar d\) are \(-0.75,1.25,-1.75,1.25\); their squared values sum to \(0.5625+1.5625+3.0625+1.5625=6.75\). Therefore \(s_D^2=6.75/3=2.25\), and the paired standard error is \(s_D/\sqrt{4}=\sqrt{2.25/4}=0.75\).
For comparison, the sample variance of A’s losses is \(10/3\): their mean is 3 and their squared deviations sum to 10. The sample variance of B’s losses is \(2.75/3=0.9167\): their mean is 3.25 and their squared deviations sum to 2.75. Treating the two loss averages as independent would give the standard-error estimate \(\sqrt{(10/3+2.75/3)/4}=\sqrt{4.25/4}\approx1.031\), which is larger than the paired estimate \(0.75\). The paired calculation is the appropriate one because each row evaluates both ensembles on the same observation.
Shared Loss Components and Ranking Precision
A simple model shows how shared losses can cancel. Suppose a paired loss can be written as \(L_A=C+U\) and \(L_B=C+V\), where \(C\) is a common component and \(U,V\) are ensemble-specific components. If \(C,U,V\) are mutually independent and have finite variances, then \(\operatorname{Var}(L_A-L_B)=\operatorname{Var}(U-V)=\operatorname{Var}(U)+\operatorname{Var}(V)\). The common component contributes to each ensemble’s risk variability but disappears from their difference.
Worked Example: A Common Component Cancels
Let \(C,U,V\) be independent, with \(C\sim\operatorname{Bernoulli}(0.5)\), \(U\sim\operatorname{Bernoulli}(0.5)\), and \(V\sim\operatorname{Bernoulli}(0.4)\). Set \(L_A=C+U\) and \(L_B=C+V\). These are nonnegative losses between 0 and 2.
The risks are \(E[L_A]=0.5+0.5=1.0\) and \(E[L_B]=0.5+0.4=0.9\), so \(\Delta=0.1\). The variance of A’s loss is \(0.25+0.25=0.50\), and the variance of B’s loss is \(0.25+0.4(0.6)=0.49\). Their covariance is \(\operatorname{Cov}(C+U,C+V)=\operatorname{Var}(C)=0.25\), because the other components are mutually independent.
Consequently, the paired difference has variance \(0.50+0.49-2(0.25)=0.49\). Indeed, \(L_A-L_B=U-V\), so the common component cancels exactly. If the two losses were incorrectly treated as independent, the variance would instead be \(0.50+0.49=0.99\). For an average over \(n\) independent observations, these become \(0.49/n\) and \(0.99/n\), respectively.
Common Mistake: Forgetting Which Losses Belong Together
A common mistake is to compare the two empirical risks as if they came from independent test samples, using a variance based only on \(\operatorname{Var}(L_A)+\operatorname{Var}(L_B)\). That discards the covariance term even when both ensembles were evaluated on the same observations. The correction is to calculate \(d_i=L_{Ai}-L_{Bi}\) for every observation first, then estimate uncertainty from the sample variance of those paired differences.
Pairing does not guarantee lower uncertainty: it helps when the paired losses have positive covariance and can hurt when that covariance is negative. Nor does pairing fix dependence between evaluation observations. The formulas above assume an independent evaluation sample; repeated or clustered observations require uncertainty calculations that account for their dependence. If ensemble fitting is random, the stated variance describes evaluation-sample uncertainty conditional on the fitted ensembles. Variation across training sets is a separate source of uncertainty, summarized by the law of total variance when the target requires it.
Check Your Understanding
Use the definitions and results above to answer these questions.
- Under the stated convention, what does a negative value of \(\hat\Delta\) say about the observed risks?
- Write the variance of \(\hat\Delta\) in terms of the two loss variances and their covariance. When does positive covariance reduce uncertainty?
- Why should the sample variance for a paired comparison be calculated from the \(d_i\), rather than from the two loss lists separately?
- In the common-component example, which part of the losses determines \(L_A-L_B\), and why?
- What additional dependence issue arises if evaluation observations are clustered rather than independent?