Covariate imbalance and balance P values: reproducible calculations and figures
Description
Python code accompanying the preprint "Randomization protects the average, not the trial: chance covariate imbalance and a calibration of balance P values at the design stage" by William J. Dwyer and David Zurakowski.
imbalance_calculations.py recomputes every derived number in the paper and its Additional file 1 and runs the Monte Carlo checks, including a small-trial check with t-tests; make_figures.py draws all figures from the formulas and from fixed-seed simulations. expected_output.txt gives the full output for comparison.
In preparing this code the author used a generative-AI assistant (Claude, Anthropic) for drafting and checking. All AI-assisted output was reviewed and verified by the author, who takes full responsibility for the code.
Version 1.1 (14 November 2026) adds a check of the ANCOVA variance inflation factor of Senn, König and Posch (Additional file 1, D3.5) to imbalance_calculations.py and sets variables in italic in the figures drawn by make_figures.py. All other output is unchanged.
Files
expected_output.txt
Files
(70.8 kB)
| Name | Size | |
|---|---|---|
|
md5:cefb23dd0d2f358b55e4d1ea8cb72ee1
|
836 Bytes | Download |
|
md5:7e6788b189a9e0bde6cdead7432747b8
|
5.9 kB | Preview Download |
|
md5:58262393ab6e05720ceafa0044da1b77
|
17.5 kB | Download |
|
md5:ca6c02a304fd6fc3530edc7f678cf62e
|
1.1 kB | Download |
|
md5:09178a7fc71fe75268f8b475d69f2306
|
43.1 kB | Download |
|
md5:afb7da66bd8466015a48569d151980cd
|
2.3 kB | Preview Download |
|
md5:a9fc6833781dbab02ea67a1474f9cbf7
|
52 Bytes | Preview Download |
Additional details
Related works
- Is supplement to
- Preprint: 10.5281/zenodo.24210825 (DOI)