Stepwise Multiple Testing Procedure
The Stepwise Multiple Testing Procedure (StepM) of Romano and Wolf (2005) names every ticker that beats the benchmark, not only whether the best one does, while holding the probability of naming any ticker that does not (the familywise error rate) at alpha. Each step tests the tickers not yet found and removes the ones found, which makes it more powerful than testing every ticker against the same critical value.
The formula for the Stepwise Multiple Testing Procedure starts from the excess return \(d_{k , t}\) of every ticker k over the benchmark in period t and its average over the n periods:
\[d_{k,t} = \text{Return}_{k,t} - \text{Benchmark Return}_{t}\] \[\bar{d}_{k} = \frac{\sum_{t=1}^{n} d_{k,t}}{n}\]The statistic \(T_{k}\) of each ticker is its studentized average excess return, with hat(omega_k) the standard deviation of sqrt(n) * bar(d_k) under the stationary bootstrap:
\[T_{k} = \frac{\sqrt{n} \cdot \bar{d}_{k}}{\hat{\omega}_{k}}\]In every step the critical value c is the 1 - alpha quantile \(Q_{1 - \alpha}\), over the B bootstrap resamples with averages bar(d_{k,b}), of the largest recentered statistic among the tickers not yet found:
\[c = Q_{1-\alpha}\left(\max\left(\frac{\sqrt{n} \cdot (\bar{d}_{k,b} - \bar{d}_{k})}{\hat{\omega}_{k}}\right)\right)\]Every ticker not yet found with \(T_{k}\) above c outperforms the benchmark; the step repeats on the remaining tickers until it finds no further one. The tickers found are those that beat the benchmark at the familywise error rate alpha, and the step at which each was found shows how clear its lead is. A ticker not found may still beat the benchmark by too little to tell apart from chance.
A data-snooping test asks whether the best of many strategies, funds or trading rules beats a benchmark once the search for the best is taken into account. Picking the best of many and testing it on its own overstates its significance: among enough strategies without any edge, one beats the benchmark by chance. These tests treat the tickers as the strategies searched and judge the best one against the bootstrapped distribution of the best of all of them. The null hypothesis is that no ticker beats the benchmark on average, the alternative that at least one does. The bootstrap draws B resamples of the periods with the stationary bootstrap of Politis and Romano (1994), blocks of consecutive periods of a random length, which keeps the dependence of the returns over time. A p-value below the chosen significance level (such as 0.05) means the best ticker still beats the benchmark after the search; the result only covers the tickers tested, not the strategies tried and discarded before.
Also known as: StepM, Romano-Wolf, multiple testing of strategies.
In the Finance Toolkit this is get_data_snooping_test with method="stepm", the same function as Data Snooping Test.
Example · XLK, XLF, XLE, XLV, 5 more · 2016 to 2025
Install the Finance Toolkit with pip install financetoolkit -U, then call get_data_snooping_test:
from financetoolkit import Toolkit
toolkit = Toolkit(
["XLK", "XLF", "XLE", "XLV", "XLY", "XLP", "XLI", "XLU", "XLB"],
api_key="FINANCIAL_MODELING_PREP_KEY",
start_date="2016-01-01",
end_date="2025-12-31",
)
toolkit.econometrics.get_data_snooping_test(method="stepm")
| Parameter | Type | Description | Example |
|---|---|---|---|
period | str | The data frequency for returns. Options are: “daily”, “weekly”, “monthly”, “quarterly”, “yearly”. Defaults to “daily”. | "weekly" |
method | str | The test. Options are: “spa” (Superior Predictive Ability Test, Hansen), “reality_check” (Reality Check, White), “stepm” (Stepwise Multiple Testing Procedure, Romano and Wolf’s StepM). Defaults to “spa”. | "spa" |
alpha | float | The familywise error rate of the StepM test: the probability of naming a ticker that does not beat the benchmark. Defaults to 0.05. | 0.01 |
n_bootstrap | int | The number of bootstrap resamples B. Defaults to 1000. | 1000 |
block_size | int | None | The average block length of the stationary bootstrap, in periods. Defaults to None, which uses the cube root of the number of periods, rounded. | None, which uses the cube root of the number of periods, rounded |
studentize | bool | Whether the SPA and StepM tests divide every average by \(\hat{\omega}_{k}\), as Hansen and Romano and Wolf recommend. The Reality Check is never studentized. Defaults to True. | True |
seed | int | The seed of the bootstrap. Defaults to 0. | 42 |
rounding | int | None | The number of decimals to round the results to. Defaults to None, which uses the rounding of the Toolkit (4 unless set otherwise). | 2 |
show_columns | str | list[str] | None | The columns to keep, a name or a list of names, matched on every column level, or the rows when no column has those names (such as the line items of a financial statement). Names that do not exist are logged, and when none exist the result is returned in full. Defaults to None, which keeps every column. | None, which keeps every column |
Which returns:
| Item | Average Excess Return | Statistic | Outperforms | Step |
|---|---|---|---|---|
| XLK | 0.0003 | 3.0024 | 1 | 1 |
| XLU | 0.0000 | -0.1316 | 0 | |
| XLF | 0.0000 | -0.1507 | 0 | |
| XLY | 0.0000 | -0.2179 | 0 | |
| XLE | -0.0001 | -0.2699 | 0 | |
| XLI | 0.0000 | -0.3250 | 0 | |
| XLB | -0.0001 | -0.9878 | 0 | |
| XLV | -0.0002 | -1.3047 | 0 | |
| XLP | -0.0003 | -1.9205 | 0 |
9 rows
Using Your Own Data
get_data_snooping_test runs on any data, not only prices: ratios, economic indicators, yield curves or your own dataset. Pass a DataFrame, a Series or a dictionary of them to Econometrics as data, with the dates in the rows or the columns, and set changes to how its changes are calculated: "percentage", "log", "difference" for rates and ratios, or None when the data are changes already. For example, for the monthly unemployment rates of the United States and Germany:
from financetoolkit import Economics, Econometrics
economics = Economics(start_date="2000-01-01")
unemployment = economics.get_unemployment_rate(
countries=["United States", "Germany"], period="monthly"
)
econometrics = Econometrics(data=unemployment, changes="difference")
econometrics.get_data_snooping_test()
References
- Paper Romano, J.P. and Wolf, M. (2005). “Stepwise Multiple Testing as Formalized Data Snooping.” Econometrica, 73(4), 1237-1282.
- Paper Politis, D.N. and Romano, J.P. (1994). “The Stationary Bootstrap.” Journal of the American Statistical Association, 89(428), 1303-1313.
- Library Referenced against arch’s StepM (Stepwise Multiple Testing Procedure)