The multiplicity ledger
CodeSplash records every hypothesis test you run. Learn to read the ledger, decide what belongs in a family, adjust p-values together, and lock a plan so that nobody can quietly change it.
You will be able to
- Find every test you ran on a dataset, with raw and adjusted p-values
- Decide which tests belong in one family
- Create and lock a confirmatory family
- Use the Counted switch honestly
Read first
Six tests on one dataset
PredictPredict first
You ran six tests on one dataset, with p-values , , , , and . Four are below 0.05. How many stay there after a Benjamini–Hochberg adjustment at 0.05?
Make your guess between 0 and 6 tests below 0.05, then reveal.
Reveal
Two. and go up to . Whether they "count" depends on what else you tested alongside them, and only a record of all six can tell you that.
What the ledger keeps
ReadThe ledgerMultiple-testing ledgerCodeSplash's record of every hypothesis test in a project, used to adjust for multiple comparisons. is the Multiple testing page in Analyze. Each hypothesis test that a saved analysis reports appears there, with these columns:
| Column | Tells you |
|---|---|
| p and Adjusted | The raw value, and the value after the family's adjustment |
| Family | Which tests it's adjusted with |
| Counted | Whether it's included in the adjustment |
| Exploratory | Whether it's labeled as a look you didn't plan |
Each dataset starts with one automatic family: exploratory, using Benjamini–HochbergBenjamini–Hochberg procedureControls the false discovery rate by comparing sorted p-values with rising thresholds. at 0.05. Nothing needs setting up, so the count starts with your first test.
See the step-up
ExploreBenjamini–Hochberg is what the automatic family applies. Move the number of tests and the number of real effects, and compare what it rejects with Bonferroni.
BExplorable · The Benjamini–Hochberg step-up
How does controlling the false discovery rate find more than Bonferroni while keeping errors in check?
How many tests will Benjamini–Hochberg reject?
Commit your prediction above to see the result
Make your prediction to see the result.
Notice how the threshold rises along the sorted p-values: the more small p-values you have, the more you can afford. That's why FDRFalse discovery rateThe expected share of false positives among the results you call significant. suits exploration, where you expect several real leads. A confirmatory family usually wants FWERFamily-wise error rateThe chance of at least one false positive across a family of tests. control with HolmHolm correctionA step-down version of Bonferroni that controls the same error rate with more power; use it instead..
By hand, once
CheckpointBenjamini–Hochberg on the six p-values
Sort the p-values and compare each with .
- , and : both pass.
- , , and : all fail.
Try this step yourself, then reveal it
The largest that passes is 2, so reject the first two.Try this step yourself, then reveal it
Adjusted p-values are the same idea, turned around: .
Check yourself
Now use Holm at on the same six p-values. How many are rejected?
Show the answer
Answer: 1
passes. fails, so stop. One rejection: the stricter promise costs a discovery.
from statsmodels.stats.multitest import multipletests
pvals = [0.001, 0.012, 0.03, 0.04, 0.20, 0.75]
print(multipletests(pvals, alpha=0.05, method="fdr_bh")[1])
print(multipletests(pvals, alpha=0.05, method="holm")[1])pvals <- c(0.001, 0.012, 0.03, 0.04, 0.20, 0.75)
p.adjust(pvals, method = "BH")
p.adjust(pvals, method = "holm")What makes a family?
CheckpointA family is the set of tests that answer one question, and whose results you'd act on together.
Check yourself
A study has one primary outcome and three secondary ones. You also ran a dozen unplanned subgroup checks. How would you organize them?
Show the answer
Answer: c
Splitting by purpose keeps planned hypotheses from paying for unplanned looks, and keeps the looks on record. A family can't be chosen by which results look good.
Check yourself
Your confirmatory family has five tests. The fifth has spoiled the adjustment, and you'd like to move it to another family. Is that fine?
Show the answer
Answer: c
Choosing the family after seeing results is p-hacking one level up. That's what locking is for.
Lock it
In the appOpen Multiple testing and press New family. Choose Confirmatory, an error rate and an adjustment, and add a note saying why the tests belong together. Then open the dataset's exploratory family and use the Family menu in each row to move tests in.
Open your new family and press Lock. The tests, the adjustment and α are frozen and recorded with a hash. Reruns still update the results, but no test can be added or removed, and you can't undo it. Do it before you look at the results.
The switch you'll be tempted by
PredictPredict first
Counted can take a test out of the adjustment. One of your tests is pushing the others above the threshold. Can you turn its Counted switch off?
Reveal
Only if it's a real sensitivity analysis: a rerun of a planned test under another assumption, chosen for that reason and not for its effect on the numbers. The ledger keeps it either way, with a dash in Adjusted, so a reader can see what you left out.
It remembers your reruns
ReadRerun an analysis with other options, and the ledger counts the newest run. The older ones stay under Earlier runs, kept for the audit trail.
When one outcome has been tried in more than three variants, the family shows a warning: "was tested in… variants… Report every variant, or pre-specify one in a confirmatory family." That's your garden of forking paths, counted for you. The ledger can't see forks that you took in your head, or in another tool. It only records what ran here.
Recap
Recap- The ledger records every test from a saved analysis, with raw and adjusted p-values, so you can always quote the denominator.
- A family is the tests that answer one question. Choose it before results, and lock it.
- Counted and Exploratory describe your tests, so set them by what the test is, never by what it did to the numbers.
Concepts in this lesson