4.6 Selection bias and multiple testing
Motivation
Researchers do not run one backtest. They run hundreds: parameter grids, universes, filters, exits. The best result is then reported. The best of many noisy estimates is biased upward, and the bias can be computed. This section computes it, gives three ways to control error rates across many tests, and describes two tools (White's Reality Check and the probability of backtest overfitting) that work directly on the set of backtests.
Reading guide
4.6.1–4.6.3 (the expected maximum Sharpe ratio of noise trials and the deflated Sharpe ratio) and the research protocol of 4.6.7 are for every reader; the playbooks and C2 use them. The proofs in 4.6.4 (Bonferroni, Holm, Benjamini–Hochberg), White's Reality Check (4.6.5) and the CSCV construction of the probability of backtest overfitting (4.6.6) are advanced and can be skipped on a first reading.
4.6.1The problem in one line#
If you test independent rules with no edge at level , the probability of at least one false "discovery" is : 40% for , 87% for , 99.4% for .
4.6.2The expected maximum Sharpe ratio of noise#
Proposition 4.13expected maximum of Gaussians
Let be iid and . Then converges in distribution to the standard Gumbel law , where and . Hence
where is the Euler–Mascheroni constant. For trial Sharpe ratios that are iid , .
Proofsketch at the level of Leadbetter, Lindgren and Rootzén, 1983, Ch. 1
First, . Choose with . The normal tail satisfies as (Mills' ratio), so for fixed and ,
Hence and . Any asymptotically equivalent to gives the same limit. The choice makes the approximation exact at , since then ; by the same Mills-ratio argument it is . The mean of the standard Gumbel law is : with ,
So . (Convergence of the mean, not only of the distribution, follows from uniform integrability of , which holds for Gaussian tails.)∎
The right-hand side of (4.17) is a pure number: in units of the cross-trial standard deviation of the Sharpe estimates. With , (4.17) gives 1.574598 for , 2.530603 for and 3.255122 for , and the module's code reproduces these values from (4.17) directly. The Gumbel approximation slightly overstates the exact mean :
| Gumbel approximation (4.17) | Exact | |
|---|---|---|
| 2 | 0.5198 | 0.5642 () |
| 10 | 1.5746 | 1.5388 |
| 100 | 2.5306 | 2.5076 |
| 1000 | 3.2551 | 3.2414 |
For the approximation is poor; it is designed for large .
From units to Sharpe ratios Under the null that no trial has skill, each per-period has standard deviation by (4.13). So per period and annualised.
Worked example 4.7
You try 100 variants of a breakout rule on five years of daily data (), and none has any edge. The annualised standard deviation of each Sharpe estimate is . The expected best annualised Sharpe ratio is . With three years of data it is 1.46, and with 1,000 variants over three years it is 1.88. An annualised Sharpe ratio of 1.5 from the best of a few hundred backtests is what pure noise produces.
4.6.3The deflated Sharpe ratio#
Bailey and López de Prado (2014) replace the benchmark in the PSR by the expected maximum under the null:
where is the number of independent trials and the variance of the Sharpe estimates across trials. In practice is estimated by clustering correlated trials (strategies that differ only slightly are not independent), and is the sample variance of the trial Sharpe ratios.
Worked example 4.8
The best of trials shows an annualised Sharpe ratio of 1.5 over five years of daily data, with , . Per day . Take , so per day (1.13 annualised). The variance factor is . Then
The undeflated is 0.9994. After deflation, the probability that the true Sharpe ratio exceeds what selection alone would produce is 0.79, below the usual 0.95 bar. With the DSR falls to 0.54; with it is 0.96. The number of trials you admit to is the most important input in the calculation.
4.6.4Family-wise error and false discovery rate#
Test hypotheses with -values . Let be the set of true nulls, , the number of true nulls rejected, and the total number rejected. A valid -value for a true null satisfies .
- Family-wise error rate: .
- False discovery rate (Benjamini and Hochberg 1995): .
FWER control is right when a single false positive is costly, such as deploying capital on one strategy. FDR control is right when screening many candidates for further work, such as a list of factors to investigate.
Proposition 4.14Bonferroni
Rejecting when gives under any dependence.
Proof
.∎
Proposition 4.15Holm 1979
Order the -values . Reject , where is the first index with (reject all if there is none). Then under any dependence, and Holm rejects every hypothesis Bonferroni rejects.
Proof
Suppose some true null is rejected, and let be the step at which the first true null is rejected. All hypotheses rejected before step are false nulls, so , that is . The rejected true null has . Therefore , and by the union bound . Holm's thresholds are all at least , so it rejects at least what Bonferroni rejects.∎
Proposition 4.16Benjamini–Hochberg 1995
Let and reject . If the true-null -values are independent of each other and of the false-null -values, then .
Proof
Write . Fix and let be the number of BH rejections when is replaced by 0; is a function of the other -values only.
Claim: for each , . If and , lowering to 0 only shifts order statistics at or below 's position. The values above position do not change, so the conditions for still hold, and can only fall. Hence . Conversely, if and , then at least of the original -values are (the others rejected with , and itself), so . If , then lowering to 0 keeps , giving , a contradiction. So .
On we have . Using the claim and independence,
Summing over the true nulls gives .∎
Under arbitrary dependence, Benjamini and Yekutieli (2001) show that replacing by restores control. Backtests of related rules on the same market are strongly dependent, so this matters.
Worked example 4.9
Eight swing-rule variants give -values 0.001, 0.008, 0.039, 0.041, 0.042, 0.060, 0.074, 0.205 at .
- Unadjusted: five rejections.
- Bonferroni (): one rejection.
- Holm: rejects; stops. One rejection.
- BH: thresholds are 0.00625, 0.0125, 0.01875, 0.025, 0.03125, 0.0375, 0.04375, 0.05. The largest with below its threshold is (0.008 ≤ 0.0125). Two rejections.
Harvey, Liu and Zhu (2016) They catalogue 316 factors proposed to explain the cross-section of US expected returns, apply Bonferroni, Holm and Benjamini–Hochberg–Yekutieli adjustments to the growing set of tests over time, and conclude that a newly proposed factor should clear a -ratio of about 3.0 rather than 2.0, and that many published findings are likely false. For orientation, the Bonferroni two-sided cut-off at is 1.96 for , 2.81 for , 3.48 for and 3.76 for . Their figure of about 3.0 comes from less conservative methods applied to the time path of discoveries. For a private researcher the lesson is concrete: if you have tried 100 things, your is not evidence.
4.6.5White's Reality Check#
Bonferroni and Holm ignore the correlation between rules, which makes them conservative for families of similar strategies. White (2000) tests the best rule directly against the distribution of the best rule under the null.
Let be the excess return of rule over a benchmark (for example buy-and-hold) at , , and its mean. The null is : no rule beats the benchmark. The statistic is . Its null distribution is approximated by resampling time periods with the stationary bootstrap of Politis and Romano (1994), which draws blocks of random geometric length to preserve serial dependence, and computing
Recentring by imposes the null in the least favourable configuration (all means equal to zero). The -value is the fraction of . Because the maximum is taken jointly over all rules in every bootstrap draw, the correlation between rules is handled automatically.
Hansen (2005) showed the test loses power when the family contains many very poor rules, and proposed the Superior Predictive Ability (SPA) test, which studentises and drops clearly inferior rules. Romano and Wolf (2005) extended the approach to a step-down procedure (StepM) that identifies which rules beat the benchmark. The arch Python package implements SPA and StepM. The code reality_check implements White's version; its test checks that 30 noise rules give a -value above 0.05 and that adding a genuine edge to one rule gives a -value below 0.05.
The essential requirement is that must be every rule you tried, not only the ones you kept. A Reality Check over the 26 survivors of an unrecorded search is meaningless.
4.6.6The probability of backtest overfitting#
Bailey, Borwein, López de Prado and Zhu (2017) ask a different question: if I choose the best variant in-sample, how often is it below median out-of-sample?
Algorithm 4.3combinatorially symmetric cross-validation, CSCV
Input: a matrix of per-period returns of variants.
- Split the rows into contiguous blocks of equal length ( even, e.g. 16).
- For each of the ways to choose half the blocks as in-sample (IS), with the rest out-of-sample (OOS):
- compute each variant's Sharpe ratio on IS rows and on OOS rows;
- let be the IS-best variant; let be its OOS rank divided by (rank 1 = worst);
- record the logit .
- fraction of splits with .
If the variants are all noise, the IS winner's OOS rank is uniform and . If one variant has a genuine edge, it wins IS and stays above median OOS, and PBO is near 0. A high PBO means your selection procedure is choosing noise. With there are 12,870 splits. The symmetric design means every block is IS in half the splits and OOS in the other half, which avoids the arbitrariness of a single hold-out.
The method assumes that the variants are the whole search, and that blocks are long enough for serial dependence not to leak across block boundaries. It says nothing about whether the family of variants has an edge: a family of uniformly good strategies can have a high PBO simply because their OOS ranks are random. Read it together with DSR.
4.6.7A research protocol#
- Keep a research log. Every backtest run, including failed ideas, is a line with date, hypothesis, parameters and result. in the DSR is the number of lines, adjusted for correlation.
- State the hypothesis and the economic reason before testing. Momentum (4.3) has a documented mechanism; "RSI 37 crossing on Tuesdays" does not.
- Reserve a final hold-out period that you touch once.
- Report: the full distribution of trial Sharpe ratios, DSR, PBO, the walk-forward curve, turnover and breakeven cost.
- Require a margin. Post-publication evidence (Case study 4.7.1) says that even published, peer-reviewed effects lose about half their return. Assume yours will lose more.
Data lab Open on OI Charts (opens in a new tab)
A Nifty trend rule, with costs
The rule is long (or short) the Nifty when at the close of day , and holds that position over day : the one-bar lag of Proposition 4.8. Net daily return is with the cost per side. Cash earns zero, so compare the rule's Sharpe ratio with buy and hold rather than reading it as an excess return.
What to look at
- The gap between the gross and net curves is the cost drag of Proposition 4.10. Compare the break-even cost with the 11.9 bp per side delivery cost of worked example 4.3.
- The Sharpe ratio is shown with standard errors from (4.13). Most settings do not separate the rule from buy and hold.
- Every distinct you try is counted. The last row is the expected best annualised Sharpe of that many rules with no edge over this sample, (4.17). Proposition 4.2 says that under a random walk any timing profit is a diluted share of the drift.
Questions
- Find the with the best net Sharpe. How many variants did you try, and does the best one beat the noise benchmark in the table? Compute its deflated Sharpe ratio (4.18) with equal to your count.
- For , , how does the break-even cost compare with realistic costs for a Nifty ETF and for Nifty futures? What turnover would make the rule unprofitable at 11.9 bp per side?
- Switch to long/short. Where does the extra return or loss come from, in terms of the drift and autocovariance terms of (4.2)?
- Does the rule's maximum drawdown improve on buy and hold? Is that evidence of timing skill or of lower exposure?